Jupyter notebook example: Use temp file
This commit is contained in:
parent
db16b16533
commit
69c6b4188d
|
@ -13,11 +13,12 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from IPython.display import SVG, display\n",
|
||||
"import tempfile, os\n",
|
||||
"\n",
|
||||
"import sys\n",
|
||||
"#sys.path.append('/PATH/TO/boxes') # uncomments and adjust if your Boxes.py copy in not in the Python path\n",
|
||||
|
@ -26,7 +27,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"execution_count": 8,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
|
@ -35,7 +36,7 @@
|
|||
"data": {
|
||||
"image/svg+xml": [
|
||||
"<svg height=\"210mm\" version=\"1.1\" viewBox=\"0 9790 170 210\" width=\"170mm\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
|
||||
"<g id=\"surface90\">\n",
|
||||
"<g id=\"surface11\">\n",
|
||||
"<path d=\"M 150 50.103125 L 0 50.103125 M 0 50.103125 L -3 50.103125 C -3.054688 50.103125 -3.101562 50.060156 -3.101562 50.001562 M -3.101562 50.001562 L -3.101562 50.001562 M -3.101562 50.001562 L -3.101562 37.001562 M -3.101562 37.001562 C -3.101562 36.946875 -3.058594 36.9 -3 36.9 M -3 36.9 L 0 36.9 C -0.0546875 36.9 -0.101562 36.942969 -0.101562 37.001562 M -0.101562 37.001562 L -0.101562 28.001562 C -0.101562 28.05625 -0.0585938 28.103125 0 28.103125 M 0 28.103125 L -3 28.103125 C -3.054688 28.103125 -3.101562 28.060156 -3.101562 28.001562 M -3.101562 28.001562 L -3.101562 22.001562 M -3.101562 22.001562 C -3.101562 21.946875 -3.058594 21.9 -3 21.9 M -3 21.9 L 0 21.9 C -0.0546875 21.9 -0.101562 21.942969 -0.101562 22.001562 M -0.101562 22.001562 L -0.101562 13.001562 C -0.101562 13.05625 -0.0585938 13.103125 0 13.103125 M 0 13.103125 L -3 13.103125 C -3.054688 13.103125 -3.101562 13.060156 -3.101562 13.001562 M -3.101562 13.001562 L -3.101562 0.0015625 M -3.101562 0.0015625 L -3.101562 -5.998438 C -3.101562 -6.053125 -3.058594 -6.1 -3 -6.1 M -3 -6.1 L 0 -6.1 M 0 0.0015625 \" style=\"fill:none;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;\" transform=\"matrix(-1,-0.000000000000000122,-0.000000000000000122,1,153.851562,9949.045313)\"/>\n",
|
||||
"<path d=\"M 0 -0.000000000000028422 C 1.867188 -0.000000000000028422 1.867188 -2.796875 0 -2.796875 C -1.863281 -2.796875 -1.863281 -0.000000000000028422 0 -0.000000000000028422 \" style=\"fill:none;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,100%);stroke-opacity:1;stroke-miterlimit:10;\" transform=\"matrix(-0.000000000000000184,-1,-1,0.000000000000000184,142.453125,9959.046875)\"/>\n",
|
||||
"<path d=\"M 0 0 C -0.0546875 0 -0.101562 0.046875 -0.101562 0.101562 M -0.101562 0.101562 L -0.101562 -2.898438 C -0.101562 -2.84375 -0.0585938 -2.796875 0 -2.796875 M 0 -2.796875 L -9 -2.796875 C -8.945312 -2.796875 -8.898438 -2.839844 -8.898438 -2.898438 M -8.898438 -2.898438 L -8.898438 0.101562 C -8.898438 0.046875 -8.941406 0 -9 0 M -9 0 L 0 0 \" style=\"fill:none;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,100%);stroke-opacity:1;stroke-miterlimit:10;\" transform=\"matrix(1,-0,-0,-1,143.351562,9946.046875)\"/>\n",
|
||||
|
@ -112,10 +113,13 @@
|
|||
" self.close()\n",
|
||||
"\n",
|
||||
"b = Example()\n",
|
||||
"b.parseArgs(['--reference=0', '--debug=0'])\n",
|
||||
"fd, fn = tempfile.mkstemp()\n",
|
||||
"b.parseArgs(['--reference=0', '--debug=0', '--output=' + fn])\n",
|
||||
"b.render()\n",
|
||||
"\n",
|
||||
"display(SVG(b.output))"
|
||||
"display(SVG(fn))\n",
|
||||
"os.close(fd)\n",
|
||||
"os.remove(fn)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue