开发者

iPython wx support?

开发者 https://www.devze.com 2023-03-05 23:14 出处:网络
This question is very similar to one I recently asked: Python threading- returning control to the terminal while keeping a frame open except I\'d like to know how to use iPython interactively with wxP

This question is very similar to one I recently asked: Python threading- returning control to the terminal while keeping a frame open except I'd like to know how to use iPython interactively with wxPython.

For example, I'd like this little script to return control to the terminal after it's opened up a frame:

from wxPython.wx import *

class MyApp(wxApp):
    def OnInit(self):
        frame = wxFrame(NULL, -1, "Hello from wxPython")
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

app = MyApp(0)
app.MainLoop()

Using "ipython -pylab" works brilliantly with plt.show() but it does not return control to the terminal with frame.Show(True).

I understand that 开发者_开发知识库iPython 0.11 will have a magic interface for this, but what are people using to have an interactive session with wxPython in the meantime?

Thanks! --Erin


A few modifications to the script needed to be made:

import wx

class MyApp(wx.App):
    def OnInit(self):
        frame = wx.Frame(None, -1, "Hello from wxPython")
        frame.Show(True)
        self.SetTopWindow(frame)
        return True

app = MyApp(0)
app.MainLoop()

Note the difference in how wx is imported- the rest of the changes just support the newer statement. Run with ipython -pylab -wthread and it works fine :)

0

精彩评论

暂无评论...
验证码 换一张
取 消