]>
Commit | Line | Data |
---|---|---|
6e18ca6c RD |
1 | from time import sleep |
2 | from threading import Thread | |
3 | ||
4 | def test_a_window(): | |
5 | print "starting window thread" | |
6 | ||
7 | from wxPython.wx import * # <-- the wxWin DLL is not loaded until here | |
8 | ||
9 | app = wxPySimpleApp(1) | |
10 | frame = wxFrame(None, -1, "Hello", size=(400,200)) | |
11 | frame.Show(true) | |
12 | EVT_SIZE(frame, OnFrameSize) | |
13 | app.MainLoop() | |
14 | print "finishing window thread" | |
15 | ||
16 | def OnFrameSize(evt): | |
17 | print evt.GetSize() | |
18 | ||
19 | ||
20 | ||
21 | keep_going = 1 | |
22 | def counter(): | |
23 | print "starting counter thread" | |
24 | count = 0 | |
25 | while keep_going: | |
26 | sleep(1) | |
27 | count += 1 | |
28 | print count | |
29 | print "finishing counter thread" | |
30 | ||
31 | def main(): | |
32 | print "main startup" | |
33 | ||
34 | ct = Thread(target=counter) | |
35 | wt = Thread(target=test_a_window) | |
36 | ||
37 | ct.start() | |
38 | wt.start() | |
39 | wt.join() | |
40 | ||
41 | global keep_going | |
42 | keep_going = 0 | |
43 | ||
44 | ct.join() | |
45 | ||
46 | print "main finished" | |
47 | ||
48 | main() | |
49 | ||
50 | ||
51 | ||
52 |