[wxPython] wxPython and threading

Works for me with wxPython 2.3.0 NT4/SP6
You may try importing into second thread.

Moving the wxPython import into the thread helps. I'm not sure why, but what
the heck... The attached code runs fine, but fails when I close the window.
The error is:

ThreadTest.py

Unhandled exception in thread:
Traceback (most recent call last):
  File "C:\Applications\Python\lib\threading.py", line 424, in __bootstrap
    self.__delete()
  File "C:\Applications\Python\lib\threading.py", line 433, in __delete
    _active_limbo_lock.acquire()
AttributeError: 'NoneType' object has no attribute 'acquire'

Hmm, that's a simple timing one, though. I need to get rid of the thread
object before I exit the program. Not sure why, but it's easy to fix...

Thanks for the pointer...

sacrificing-a-chicken-to-the-gods-of-threading-ly y'rs
Paul.

--- Cut Here ---
import threading

class AppLoop(threading.Thread):
    def run(self):
        from wxPython.wx import wxPySimpleApp, wxFrame
        app = wxPySimpleApp()
        frame = wxFrame(None, -1, "Test")
        frame.Show(1)
        app.MainLoop()

if __name__ == '__main__':
    a = AppLoop()
    a.start()
    a.join()
    a = None # Add this to prevent the above error

···

From: Niki Spahiev [mailto:niki@vintech.bg]

From: Niki Spahiev [mailto:niki@vintech.bg]
> Works for me with wxPython 2.3.0 NT4/SP6
> You may try importing into second thread.

Moving the wxPython import into the thread helps. I'm not sure why, but

what

the heck...

The thread that is active when the wxWindows DLL is loaded and initialized
is assumed to be the main thread. It would probably make more sense to have
it be the thread that is active when MainLoop is called, but I havn't looked
into doing that yet.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!