[SciPy-dev] Generic gui_thread + IPython: solution already exists!

Pearu Peterson pearu at scipy.org
Sun Nov 14 14:49:19 CST 2004



On Mon, 15 Nov 2004, Prabhu Ramachandran wrote:

> wxPython
> --------
>
> If you just start ipython -pylab you can run the wxPythonDemo
> completely interactively from IPython::
>
>    In [1]: cd /usr/local/share/doc/wxPython-2.5.2.8/demo/
>    /usr/local/share/doc/wxPython-2.5.2.8/demo
>    In [2]: import Main
>    In [3]: d = Main.wxPythonDemo(None, 'a')
>    In [4]: d.Show(1)
>    Out[4]: True
>    In [5]:
>
> This works out nicely!  I also tried a bunch of other tests and things
> work well.

With wx 2.4.2.4 I get:

In [1]: cd /opt/src/wxPythonSrc-2.4.2.4/wxPython/demo
/opt/src/wxPythonSrc-2.4.2.4/wxPython/demo

In [2]: import Main

In [3]: d = Main.wxPythonDemo(None, -1, 'a')
22:39:45: Warning: No handler found for image type.
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call 
last)

/opt/src/wxPythonSrc-2.4.2.4/wxPython/demo/<console>

/opt/src/wxPythonSrc-2.4.2.4/wxPython/demo/Main.py in __init__(self, 
parent, id, title)
     316             wx.EVT_MENU(self.tbicon, self.TBMENU_CLOSE, 
self.OnTaskBarClose)
     317
--> 318         wx.CallAfter(self.ShowTip)
     319
     320         self.otherWin = None

/usr/lib/python2.3/site-packages/wxPython/wx.py in wxCallAfter(callable, 
*args, **kw)
    1698     """
    1699     app = wxGetApp()
-> 1700     assert app, 'No wxApp created yet'
    1701
    1702     global _wxCallAfterId

AssertionError: No wxApp created yet

> Now, obviously, no other application can launch a mainloop.  So we
> need to somehow inhibit the user from being able to start it.  The
> solution is incredibly simple, replace the real mainloop with a dummy.

Could this be used in gui_thread? Do we need gui_thread anymore?

Pearu




More information about the Scipy-dev mailing list