Embed IPython embedded sample

38 views
Skip to first unread message

Christoph Schmidt-Hieber

unread,
Sep 21, 2009, 11:33:14 AM9/21/09
to wxPyth...@googlegroups.com
Hi,
I wondered whether it would be possible to embed IPython rather than Pycrust in the embedded sample. I've tried to play around with the wx frontend sample code that is provided with my IPython distribution, located in ipython/IPython/gui/wx/*.* and ipython/IPython/frontend/wx/*.* in my case. Both of these implementations seem to rely on being called from main(), since they will complain about a missing sys.argv attribute. I tried something along the lines of:

ipython_panel = IPShellWidget(self,background_color = "BLACK")
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(ipython_panel, 1, wx.EXPAND|wx.BOTTOM|wx.LEFT|wx.RIGHT, 10)

in the embedded_sample.py, which resulted in the error message attached below. Any ideas how I could avoid this problem?

Best
Christoph


error message:

Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/home/cs/wx/embedded_ipython/embedded_ipython.py", line 5, in <module>
from IPython.gui.wx.ipython_view import IPShellWidget
File "/var/lib/python-support/python2.6/IPython/__init__.py", line 58, in <module>
__import__(name,glob,loc,[])
File "/var/lib/python-support/python2.6/IPython/Shell.py", line 42, in <module>
from IPython import ultraTB, ipapi
File "/var/lib/python-support/python2.6/IPython/ultraTB.py", line 99, in <module>
from IPython import Debugger, PyColorize
File "/var/lib/python-support/python2.6/IPython/Debugger.py", line 48, in <module>
if '-pydb' in sys.argv:
AttributeError: 'module' object has no attribute 'argv'

Robin Dunn

unread,
Sep 21, 2009, 2:07:55 PM9/21/09
to wxPyth...@googlegroups.com


You can use the PySys_SetArgv() API to set sys.argv before you execute
the Python code.


--
Robin Dunn
Software Craftsman
http://wxPython.org

Christoph Schmidt-Hieber

unread,
Sep 22, 2009, 10:10:12 AM9/22/09
to wxPyth...@googlegroups.com
Hi,

Thanks a lot, that worked.
I have one more question concerning the embedded shell: I get an error message when I try to close a window that was created by pylab from the embedded shell (both with PyCrust and with IPython; see attached crash report). Pylab's wx backend attempts to call wxapp.Yield(), which doesn't seem to exist in the embedded case. Do you have any suggestions how I could work around this problem?
Thanks again,
Christoph

IPython_crash_report.txt
Reply all
Reply to author
Forward
0 new messages