Threading and wx.....

S

SamG

Hi,

Im trying my hand at threading with wx applications. I have written
the following code...

import wx
from threading import Thread, Lock

class createWindow(Thread):
def __init__(self):
Thread.__init__(self)
self.lock = Lock()
self.app=None

def run(self):
#self.lock.acquire()
self.app = wx.PySimpleApp()
frame = wx.Frame(None, title="Hello wx")
frame.Show()
#self.lock.release()
self.app.MainLoop()


if __name__=='__main__':
c = createWindow()
c.start()
c.join()

Now when i run this program i get a window but the application just
does not respond. Is there something that im missing here. Pls let me
know. Thanks in advance.
 
S

SamG

Hi,

Im trying my hand at threading with wx applications. I have written
the following code...

import wx
from threading import Thread, Lock

class createWindow(Thread):
def __init__(self):
Thread.__init__(self)
self.lock = Lock()
self.app=None

def run(self):
#self.lock.acquire()
self.app = wx.PySimpleApp()
frame = wx.Frame(None, title="Hello wx")
frame.Show()
#self.lock.release()
self.app.MainLoop()

if __name__=='__main__':
c = createWindow()
c.start()
c.join()

Now when i run this program i get a window but the application just
does not respond. Is there something that im missing here. Pls let me
know. Thanks in advance.

Oops! Murphy's law works again! And the above code is working fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,263
Messages
2,571,062
Members
48,769
Latest member
Clifft

Latest Threads

Top