[SciPy-dev] gui_thread issue

Pearu Peterson pearu at scipy.org
Sat Nov 6 16:58:28 CST 2004


On Sat, 6 Nov 2004, Fernando Perez wrote:

> eric jones wrote:
>> Do we still have the problem that gui_thread can't be started from an 
>> IPython resource file so that the user doesn't explicitly have to call 
>> gui_thread.start() (or whatever)?  My initial attempts failed.
>> I just tried something like:
>> 
>>     import gui_thread
>>     gui_thread.start()
>>     import time
>>     time.sleep(1) # any value here fails.
>>     import enthought.chaco.wxplt as plt
>
> Well, I just ran in ipython:
>
> In [1]: import gui_thread
>
> In [2]: gui_thread.start()
> <Importing wxPython...  done.>

This "<Importing wxPython...  done.>" message indicates that old
gui_thread hooks are being used. It means that you are using rather
old version of scipy. What I am missing here?

Btw, gui_thread.start(use_main=1) with recent scipy from CVS would use
old gui_thread hooks.

Now, let me report my experience with gui_thread when using wx 2.4.2.4
and recent scipy from CVS.

Example 1 (Linux, standard python)
---------
pearu at p4:~$ NOIPYTHON= python
Python 2.3.4 (#2, Sep 24 2004, 08:39:09)
[GCC 3.3.4 (Debian 1:3.3.4-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gui_thread; gui_thread.start()
>>> import os
>>> os.chdir('/opt/src/wxPythonSrc-2.4.2.4/wxPython/demo/')
>>> import Main
>>> d=Main.wxPythonDemo(None,-1,'a')
Segmentation fault
pearu at p4:~$ NOIPYTHON= python
Python 2.3.4 (#2, Sep 24 2004, 08:39:09)
[GCC 3.3.4 (Debian 1:3.3.4-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gui_thread; gui_thread.start()
>>> import os
>>> os.chdir('/opt/src/wxPythonSrc-2.4.2.4/wxPython/demo/')
>>> import Main
>>> Main.wxPythonDemo
<class Main.wxPythonDemo at 0x439f3efc>
>>> d=Main.wxPythonDemo(None,-1,'a')
>>> # Demo window pops up and is functional
>>> d.Show(1)
0
>>>

pearu at p4:~$ NOIPYTHON= python
Python 2.3.4 (#2, Sep 24 2004, 08:39:09)
[GCC 3.3.4 (Debian 1:3.3.4-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gui_thread; gui_thread.start(use_main=1)
<Importing wxPython...  done.>
>>>
>>> import os
>>> os.chdir('/opt/src/wxPythonSrc-2.4.2.4/wxPython/demo/')
>>> import Main
>>> d=Main.wxPythonDemo(None,-1,'a')
# A warning window appears (with no visible contents) and python hangs.

Example 2 (Linux, ipython 0.6.4.rc2)
---------

pearu at p4:~$ python
Python 2.3.4 (#2, Sep 24 2004, 08:39:09)
[GCC 3.3.4 (Debian 1:3.3.4-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

In [1]: import gui_thread; gui_thread.start()

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

In [3]: import Main

In [4]: d=Main.wxPythonDemo(None,-1,'a')
# Demo window pops up but then python and wx window hang.

Example 3 (Win32, standard Python prompt)
---------

C:\Documents and Settings\pearu>python
Python 2.3.3 (#51, Dec 18 2003, 20:22:39> [MSC v.1200 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import gui_thread
>>> gui_thread.start()
>>> import os
>>> import wxPython
>>> os.chdir(os.path.join(os.path.dirname(wxPython.__file__),'demo'))
>>> d=Main.wxPythonDemo(None,-1,'a')
>>> d.Show(1)
>>> # nothing happend, no demo window, nothing..
>>> ^Z

16:12:34: Debug: e:\Projects\wx2.4\src\msw\app.cpp(439): 
'UnregisterClass(canvas)' failed with error 0x00000584 (class still has 
open windows.).
16:12:34: Debug: e:\Projects\wx2.4\src\msw\app.cpp(446):
'UnregisterClass(no redraw canvas)' failed with error 0x00000584 (class 
still has open windows.).

C:\Documents and Settings\pearu>

Example 4 (Win32, standard Python prompt, wx 2.5.2.8)
---------
C:\Documents and Settings\pearu>python
Python 2.3.3 (#51, Dec 18 2003, 20:22:39> [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import gui_thread
>>> gui_thread.start()
>>> import os
>>> import wx
>>> os.chdir(os.path.join(os.path.dirname(wx.__file__),'demo'))
>>> d=Main.wxPythonDemo(None,'a')
Traceback (most recent call last):
   File "<stdin>", lin1 1, in ?
   File "C:\Py233\Lib\site-packages\wx\demo\Main.py", line 1160, in 
__init__
     self.LoadDemo(self.overviewText)
   File "C:\Py233\Lib\site-packages\wx\demo\Main.py", line 1227, in
LoadDemo
     self.LoadDemoSource()
   File "C:\Py233\Lib\site-packages\wx\demo\Main.py", line 1246, in 
LoadDemoSource
     self.codePage.LoadDemo(self.demoModules)
...
   File "C:\Py233\Lib\site-packages\wx\_core.py", line 6331, in SetFocus
     return _core_.Window_SetFocus(*args, **kwargs)
wx._core_.PyAssertionError: C++ assertion "wxThread::lsMain()" failed in 
..\..\src\common\timercmn.cpp(70): timer can only be started from the main 
thread
>>>

So, gui_thread seems to remain a troublesome module in scipy..

Pearu




More information about the Scipy-dev mailing list