ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 28 Jul 2019 00:56:54 +0200no graphics output when running python script via "sage -python script.py"https://ask.sagemath.org/question/47045/no-graphics-output-when-running-python-script-via-sage-python-scriptpy/ Hi, am writing a GUI for a python module that relies on Sage packages, so it needs to run from a terminal using sage, i.e., "sage -python programGUI.app". In the command line version of the program everything I need works great, but when I try to launch a graphic from the GUI, nothing launches. For 2d graphics I can save them to a tmp directory, then open in the GUI or elsewhere (i.e., a workaround). But for 3d graphics, which I would like to open in a browser with the option viewer="threejs", I don't see a way to save the html file that Sage generates.
The sage documentation for threejs says "The generated HTML file contains all data for the scene apart from the JavaScript library and can be saved to disk for sharing or embedding in a web page", but I don't see any way to save the HTML file to disk. When I launch a graphic in the sage command line environment the HTML file is saved to SAGE_TMP. In the below example, no file is saved to the SAGE_TMP directory, which is presumably connected to the reason the browser does not launch the html page.
Here is a very simple example that shows that nothing is saved to the SAGE_TMP directory, and for which no graphic launches:
from sage.all import *
import os
tmp = str(sage.misc.misc.SAGE_TMP)
print(tmp)
os.listdir(tmp)
S=sage.plot.plot3d.shapes.Sphere(.5)
p=S.plot()
p.show(viewer='threejs',online=True)
os.listdir(tmp)
This returns:
/Users/will/.sage/temp/williams-MacBook-Pro.local/74189
Graphics3d Object
Thanks for any help anyone can give.Wed, 03 Jul 2019 03:14:41 +0200https://ask.sagemath.org/question/47045/no-graphics-output-when-running-python-script-via-sage-python-scriptpy/Comment by gam for <p>Hi, am writing a GUI for a python module that relies on Sage packages, so it needs to run from a terminal using sage, i.e., "sage -python programGUI.app". In the command line version of the program everything I need works great, but when I try to launch a graphic from the GUI, nothing launches. For 2d graphics I can save them to a tmp directory, then open in the GUI or elsewhere (i.e., a workaround). But for 3d graphics, which I would like to open in a browser with the option viewer="threejs", I don't see a way to save the html file that Sage generates.</p>
<p>The sage documentation for threejs says "The generated HTML file contains all data for the scene apart from the JavaScript library and can be saved to disk for sharing or embedding in a web page", but I don't see any way to save the HTML file to disk. When I launch a graphic in the sage command line environment the HTML file is saved to SAGE_TMP. In the below example, no file is saved to the SAGE_TMP directory, which is presumably connected to the reason the browser does not launch the html page.</p>
<p>Here is a very simple example that shows that nothing is saved to the SAGE_TMP directory, and for which no graphic launches:</p>
<pre><code>from sage.all import *
import os
tmp = str(sage.misc.misc.SAGE_TMP)
print(tmp)
os.listdir(tmp)
S=sage.plot.plot3d.shapes.Sphere(.5)
p=S.plot()
p.show(viewer='threejs',online=True)
os.listdir(tmp)
</code></pre>
<p>This returns:</p>
<pre><code>/Users/will/.sage/temp/williams-MacBook-Pro.local/74189
Graphics3d Object
</code></pre>
<p>Thanks for any help anyone can give.</p>
https://ask.sagemath.org/question/47045/no-graphics-output-when-running-python-script-via-sage-python-scriptpy/?comment=47276#post-id-47276Similar problem. Please help!Sun, 28 Jul 2019 00:56:54 +0200https://ask.sagemath.org/question/47045/no-graphics-output-when-running-python-script-via-sage-python-scriptpy/?comment=47276#post-id-47276