]>
Commit | Line | Data |
---|---|---|
d1679124 | 1 | |
8fa876ca | 2 | import wx |
d1679124 | 3 | |
eb0f373c | 4 | haveToggleBtn = 1 |
08b89fa8 | 5 | if wx.Platform == "__WXX11__": |
eb0f373c RD |
6 | haveToggleBtn = 0 |
7 | ||
d1679124 RD |
8 | #---------------------------------------------------------------------- |
9 | ||
8fa876ca | 10 | class TestPanel(wx.Panel): |
d1679124 | 11 | def __init__(self, parent, log): |
8fa876ca | 12 | wx.Panel.__init__(self, parent, -1) |
d1679124 | 13 | self.log = log |
8fa876ca RD |
14 | panel = wx.Panel(self, -1) |
15 | buttons = wx.BoxSizer(wx.HORIZONTAL) | |
16 | ||
1e4a197e | 17 | for word in "These are toggle buttons".split(): |
8fa876ca RD |
18 | b = wx.ToggleButton(panel, -1, word) |
19 | self.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggle, b) | |
20 | buttons.Add(b, flag=wx.ALL, border=5) | |
d1679124 | 21 | |
1e4a197e | 22 | panel.SetAutoLayout(True) |
d1679124 RD |
23 | panel.SetSizer(buttons) |
24 | buttons.Fit(panel) | |
25 | panel.Move((50,50)) | |
26 | ||
27 | def OnToggle(self, evt): | |
28 | self.log.write("Button %d toggled\n" % evt.GetId()) | |
29 | ||
30 | #---------------------------------------------------------------------- | |
31 | ||
32 | def runTest(frame, nb, log): | |
eb0f373c RD |
33 | if haveToggleBtn: |
34 | win = TestPanel(nb, log) | |
35 | return win | |
36 | else: | |
c4ef95da RD |
37 | from Main import MessagePanel |
38 | win = MessagePanel(nb, 'wx.ToggleButton is not available on this platform.', | |
39 | 'Sorry', wx.ICON_WARNING) | |
40 | return win | |
eb0f373c RD |
41 | |
42 | ||
d1679124 RD |
43 | #---------------------------------------------------------------------- |
44 | ||
45 | ||
46 | overview = """\ | |
95bfd958 | 47 | wx.ToggleButton is a button that stays pressed when clicked by the user. |
8fa876ca RD |
48 | In other words, it is similar to wxCheckBox in functionality but looks like a |
49 | wxButton. | |
1fded56b | 50 | |
8fa876ca | 51 | This class is only available under wxMSW and wxGTK currently. |
1fded56b | 52 | |
8fa876ca | 53 | """ |
1fded56b RD |
54 | |
55 | ||
56 | ||
57 | if __name__ == '__main__': | |
58 | import sys,os | |
59 | import run | |
8eca4fef | 60 | run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) |