]>
Commit | Line | Data |
---|---|---|
1 | ||
2 | from wxPython.wx import * | |
3 | from wxPython.lib.grids import wxFlexGridSizer | |
4 | ||
5 | import time | |
6 | from threading import Thread | |
7 | def foo(): | |
8 | for x in range(20): | |
9 | print x, "Fooing!" | |
10 | time.sleep(0.5) | |
11 | Thread(target=foo).start() | |
12 | ||
13 | class MyFrame(wxFrame): | |
14 | def __init__(self, parent, ID, title, pos, size): | |
15 | wxFrame.__init__(self, parent, ID, title, pos, size) | |
16 | panel = wxPanel(self, -1) | |
17 | self.panel=panel | |
18 | box = wxFlexGridSizer(1, 2, 10, 10) | |
19 | box.Add(wxButton(panel, 11211, "Foo"), 0, wxCENTER) | |
20 | box.Add(wxButton(panel, 11211, "Bar"), 0, wxCENTER) | |
21 | box.AddGrowableCol(1) | |
22 | panel.SetSizer(box) | |
23 | panel.SetAutoLayout(true) | |
24 | #EVT_SIZE(panel, lambda e, p=panel: p.Layout()) | |
25 | EVT_BUTTON(self, 11211, self.Click) | |
26 | ||
27 | def Click(self, event): | |
28 | print "Click" | |
29 | ||
30 | ||
31 | class MyApp(wxApp): | |
32 | def OnInit(self): | |
33 | win = MyFrame(None, -1, "Bummer", wxDefaultPosition, (200, 100)) | |
34 | win.Show(true) | |
35 | self.SetTopWindow(win) | |
36 | return true | |
37 | ||
38 | MyApp(0).MainLoop() | |
39 |