[IPython-user] Exception embedding IPython - help please
brucedickey at micron.com
brucedickey at micron.com
Fri Oct 14 16:04:53 CDT 2005
Thanks, here is the traceback. Incidently, using red hat enterprise 3 -- had left that out
AttributeError: Prompt1 instance has no attribute 'split'
Traceback (innermost last):
File "/home/brucedickey/proj/diagnostic_framework_sdk/host_gui/diags.py", line 1, in ?
"""
File "/home/brucedickey/proj/diagnostic_framework_sdk/host_gui/diags.py", line 1296, in ?
app.MainLoop()
File "/opt/sigsw/python/lib/python2.3/site-packages/wxPython/wx.py", line 1968, in MainLoop
wxPyApp.MainLoop(self)
File "/opt/sigsw/python/lib/python2.3/site-packages/wxPython/wx.py", line 89, in MainLoop
val = wxc.wxPyApp_MainLoop(self, *_args, **_kwargs)
File "/home/brucedickey/proj/diagnostic_framework_sdk/host_gui/diags.py", line 181, in OnHelpBtn
ipshell("Here we go") # this call anywhere in your program will start IPython
File "/opt/sigsw/python/lib/python2.3/site-packages/IPython/Shell.py", line 199, in __call__
self.IP.embed_mainloop(banner,local_ns,global_ns,stack_depth=1)
File "/opt/sigsw/python/lib/python2.3/site-packages/IPython/iplib.py", line 1337, in embed_mainloop
self.interact(header)
File "/opt/sigsw/python/lib/python2.3/site-packages/IPython/iplib.py", line 1498, in interact
line = self.raw_input(prompt)
File "/opt/sigsw/python/lib/python2.3/site-packages/IPython/iplib.py", line 1690, in raw_input
return self.prefilter(raw_input_original(prompt),
File "/opt/sigsw/python/lib/python2.3/site-packages/wxPython/py/shell.py", line 772, in raw_input
self.write(prompt)
File "/opt/sigsw/python/lib/python2.3/site-packages/wxPython/py/shell.py", line 699, in write
text = self.fixLineEndings(text)
File "/opt/sigsw/python/lib/python2.3/site-packages/wxPython/py/shell.py", line 705, in fixLineEndings
lines = text.split('\r\n')
-----Original Message-----
From: Fernando Perez [mailto:Fernando.Perez at colorado.edu]
Sent: Friday, October 14, 2005 2:58 PM
To: brucedickey
Cc: ipython-user at scipy.net
Subject: Re: [IPython-user] Exception embedding IPython - help please
brucedickey at micron.com wrote:
> Python 2.3.4
> IPython 0.6.15 for Python 2.3 from the src rpm Embedding in a wxPython
> app, wxPython 2.4.2.4
>
> First time user.
>
> My code:
>
> import IPython
> from IPython.Shell import IPShellEmbed args = ['-pdb', '-pprint',
> '-debug', '-colors', 'Linux']
>
> ipshell = IPShellEmbed(args, banner = 'Entering IPython', exit_msg =
> 'Going back to main program') ipshell("Here we go") print 'Back in
> main program'
>
>
> An exception is generated in shell.py ln 705 in fixLineEndings():
> lines = text.split('\r\n'),
>
> from write(): text = self.fixLineEndings(text),
>
> from raw_input(): write(prompt).
>
> Well, prompt is a prompt object, not a string, so split() naturally
> does not work on it.
>
> Please tell me how to get around this.
Please post an actual traceback, not a paraphrase thereof. Without a real traceback, I don't know what code to actually look at. There is no fixLineEndings method anywhere in ipython, for one thing.
> Secondly, I would like to have the IPython shell available all the
> time in a wxPython window w/o it being an either/or situation (run my
> wxPython app or IPython but not both at once). I.e. Have a notebook
> control with tabs for my app's functionality and a tab for IPython so
> the user can select any tab and use what is on it at any time. Any way
> to do this? The IPython doc made it look like the app its embedded in
> is suspended while in ipshell()....
It's possible, but there is no 'out of the box' prepackaged class to do this, like there is for blocking embedding. You'll have to finagle something using the threaded classes in Shell.py (specifically, the one for WX). I know it's possible in principle, because the BrainVISA team did precisely that, but in a Qt context. You may also try to download their code for inspiration (the basic ideas are probably similar):
http://brainvisa.info/
I didn't directly work on that, so I'm not familiar with the details, nor do I know whether this functionality is in already released code or only in CVS.
You may want to send an email to their forum
(http://brainvisa.info/contact.html) to find out.
Cheers,
f
More information about the IPython-user
mailing list