GUI libs

A. Lloyd Flanagan alloydflanagan at attbi.com
Fri Apr 25 23:10:54 CEST 2003


Gerhard Haering <gh at ghaering.de> wrote in message news:<mailman.1051277805.18035.python-list at python.org>...
<big snip>
> On Windows, try this:
> 
> C:\>python
> Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> from wxPython.wx import *
>  >>> f = wxFrame(NULL, 1, "foo")
>  >>> f.Show()
> 
> This will segfault Python. IIRC, this was what I did in my very first 
> exploration of wxPython.
> 
> I believe the reason of this crash is that the wxWindows main loop isn't 
> initialized, yet. What I've done may be not very clever, but in my 

As a follow-up to my earlier reply, this seems to work well:

>>> from wxPython.wx import *
>>> from threading import *
>>> class wxThread(Thread):
...    def run(self, my_app):
...        my_app.MainLoop()
...
>>> x = wxThread()
>>> app = wxPySimpleApp()
>>> x.run(app)
>>> f = wxFrame(None, 1, "foo")
>>> f.Show()
1
>>> f.SetTitle("foobar")

etc.
You've got your application main loop running in a separate thread,
but it seems to 'see' f just fine, and window events get processed.




More information about the Python-list mailing list