]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/ToggleButton.py
Call event.Skip in OnSize
[wxWidgets.git] / wxPython / demo / ToggleButton.py
CommitLineData
d1679124 1
8fa876ca 2import wx
d1679124 3
eb0f373c 4haveToggleBtn = 1
08b89fa8 5if wx.Platform == "__WXX11__":
eb0f373c
RD
6 haveToggleBtn = 0
7
d1679124
RD
8#----------------------------------------------------------------------
9
8fa876ca 10class 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
32def runTest(frame, nb, log):
eb0f373c
RD
33 if haveToggleBtn:
34 win = TestPanel(nb, log)
35 return win
36 else:
95bfd958 37 dlg = wx.MessageDialog(frame, 'wx.ToggleButton is not available on this platform.',
8fa876ca 38 'Sorry', wx.OK | wx.ICON_INFORMATION)
eb0f373c
RD
39 dlg.ShowModal()
40 dlg.Destroy()
41
42
d1679124
RD
43#----------------------------------------------------------------------
44
45
46overview = """\
95bfd958 47wx.ToggleButton is a button that stays pressed when clicked by the user.
8fa876ca
RD
48In other words, it is similar to wxCheckBox in functionality but looks like a
49wxButton.
1fded56b 50
8fa876ca 51This class is only available under wxMSW and wxGTK currently.
1fded56b 52
8fa876ca 53"""
1fded56b
RD
54
55
56
57if __name__ == '__main__':
58 import sys,os
59 import run
60 run.main(['', os.path.basename(sys.argv[0])])