-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathSeparateThread.py
executable file
·59 lines (40 loc) · 1.14 KB
/
SeparateThread.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python
"""
simple example of runnig wxPython in a secondary thread
As of now -- all I get is a crash!
"""
import threading
import wx
import time
import DoubleBufferDemo
class MicroFrame(wx.Frame):
pass
class MicroApp(wx.App):
def OnInit(self):
f = MicroFrame(None, title="threading demo")
f.Show()
self.startup_event
return True
class wxThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.startup_event = startup_event = threading.Event()
def run(self):
print("starting up the wx app")
self.app = DoubleBufferDemo.DemoApp(False)
print("app started --- starting the mainloop")
self.startup_event.set()
self.app.MainLoop()
if __name__ == "__main__":
wxt = wxThread()
startup_event = wxt.startup_event
wxt.start()
print("thread started...")
# wait for the wx.Frame to be created
startup_event.wait()
frame = wxt.app.frame
# run an endless loop to do re-draw...
while True:
time.sleep(0.5)
print("another moment passed...")
frame.NewDrawing()