Embed IPython embedded sample

Showing 1-3 of 3 messages
Embed IPython embedded sample Christoph Schmidt-Hieber 9/21/09 8:33 AM
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'

Re: [wxPython-dev] Embed IPython embedded sample Robin Dunn 9/21/09 11:07 AM


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


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

Re: [wxPython-dev] Re: Embed IPython embedded sample Christoph Schmidt-Hieber 9/22/09 7:10 AM
Hi,

On Mon, 21 Sep 2009, Robin Dunn wrote:
> On 9/21/09 8:33 AM, Christoph Schmidt-Hieber wrote:
>> AttributeError: 'module' object has no attribute 'argv'
>
> You can use the PySys_SetArgv() API to set sys.argv before you execute
> the Python code.

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