]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/demo/ToggleButton.py
wchar_t (4 bytes) / unichar (2 bytes) problems first attempt to fix
[wxWidgets.git] / wxPython / demo / ToggleButton.py
... / ...
CommitLineData
1
2import wx
3
4haveToggleBtn = 1
5
6try:
7 wx.ToggleButton
8except NameError:
9 haveToggleBtn = 0
10
11#----------------------------------------------------------------------
12
13class TestPanel(wx.Panel):
14 def __init__(self, parent, log):
15 wx.Panel.__init__(self, parent, -1)
16 self.log = log
17 panel = wx.Panel(self, -1)
18 buttons = wx.BoxSizer(wx.HORIZONTAL)
19
20 for word in "These are toggle buttons".split():
21 b = wx.ToggleButton(panel, -1, word)
22 self.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggle, b)
23 buttons.Add(b, flag=wx.ALL, border=5)
24
25 panel.SetAutoLayout(True)
26 panel.SetSizer(buttons)
27 buttons.Fit(panel)
28 panel.Move((50,50))
29
30 def OnToggle(self, evt):
31 self.log.write("Button %d toggled\n" % evt.GetId())
32
33#----------------------------------------------------------------------
34
35def runTest(frame, nb, log):
36 if haveToggleBtn:
37 win = TestPanel(nb, log)
38 return win
39 else:
40 dlg = wx.MessageDialog(frame, 'wx.ToggleButton is not available on this platform.',
41 'Sorry', wx.OK | wx.ICON_INFORMATION)
42 dlg.ShowModal()
43 dlg.Destroy()
44
45
46#----------------------------------------------------------------------
47
48
49overview = """\
50wx.ToggleButton is a button that stays pressed when clicked by the user.
51In other words, it is similar to wxCheckBox in functionality but looks like a
52wxButton.
53
54This class is only available under wxMSW and wxGTK currently.
55
56"""
57
58
59
60if __name__ == '__main__':
61 import sys,os
62 import run
63 run.main(['', os.path.basename(sys.argv[0])])