- Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathSeparateThread.py
More file actions
Latest commit
executable file
·59 lines (40 loc) · 1.14 KB
/
Copy pathSeparateThread.py
File metadata and controls
executable file
·59 lines (40 loc) · 1.14 KB
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!
"""
importthreading
importwx
importtime
importDoubleBufferDemo
classMicroFrame(wx.Frame):
pass
classMicroApp(wx.App):
defOnInit(self):
f=MicroFrame(None, title="threading demo")
f.Show()
self.startup_event
returnTrue
classwxThread(threading.Thread):
def__init__(self):
threading.Thread.__init__(self)
self.startup_event=startup_event=threading.Event()
defrun(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...
whileTrue:
time.sleep(0.5)
print("another moment passed...")
frame.NewDrawing()