embed ipython in wxPython app

chewie54 dfabrizio51 at gmail.com
Sun Nov 18 20:39:12 EST 2007


Hi All,

I'm evaluting IPython to see if I can it use like Tcl and Tk.     If I
start wish8.4,  I get a command line
interpreter in xterm,  then I can source tcl progams that draw tk
graphics on a canvas in another window.

Is there a way to embed IPython in a wxPython app to do that?
When I do as shown in the example below the GUI window does not show
until I exit IPython.

Thanks in advance for any help with this,



import wx
from IPython.Shell import IPShellEmbed

class MyFrame(wx.Frame):
    def __init__(self,parent=None, id=-1, title=' '):
        wx.Frame.__init__(self,parent,id,title,size=(200,140))
        top = wx.Panel(self)
        sizer = wx.BoxSizer(wx.VERTICAL)
        lb = wx.StaticText(top,-1,'Animals(in pairs; min,pair,
max,dozen)')
        sizer.Add(lb)

        top.SetSizer(sizer)
        self.Layout()

class MyApp(wx.App):
    def OnInit(self):
        frame = MyFrame(title="wxWidgets")
        frame.Show(True)
        self.SetTopWindow(frame)
        return True

def main():
    ipshell = IPShellEmbed()
    ipshell()
    app = MyApp()
    app.MainLoop()

if __name__ == '__main__':
    main()



More information about the Python-list mailing list