IPython wx support?

This question is very similar to the one I recently asked: Python threading - returning control to the terminal while saving the frame , except that I would like to know how to use iPython interactively using wxPython.

For example, I would like this little script to return control to the terminal after it opens the 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 fine with plt.show (), but it does not return control to a terminal with a frame. Display (True).

I understand that iPython 0.11 will have a magic interface for this, but what do people use for an interactive session with wxPython in the meantime?

Thanks! --Erin

0
source share
1 answer

You need to make a few changes to the script:

 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 new operator. Run with ipython -pylab -wthread and it works fine :)

0
source

Source: https://habr.com/ru/post/1479011/


All Articles