]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/ToggleButton.py
11 #----------------------------------------------------------------------
13 class TestPanel(wx
.Panel
):
14 def __init__(self
, parent
, log
):
15 wx
.Panel
.__init
__(self
, parent
, -1)
17 panel
= wx
.Panel(self
, -1)
18 buttons
= wx
.BoxSizer(wx
.HORIZONTAL
)
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)
25 panel
.SetAutoLayout(True)
26 panel
.SetSizer(buttons
)
30 def OnToggle(self
, evt
):
31 self
.log
.write("Button %d toggled\n" % evt
.GetId())
33 #----------------------------------------------------------------------
35 def runTest(frame
, nb
, log
):
37 win
= TestPanel(nb
, log
)
40 dlg
= wx
.MessageDialog(frame
, 'wx.ToggleButton is not available on this platform.',
41 'Sorry', wx
.OK | wx
.ICON_INFORMATION
)
46 #----------------------------------------------------------------------
50 wx.ToggleButton is a button that stays pressed when clicked by the user.
51 In other words, it is similar to wxCheckBox in functionality but looks like a
54 This class is only available under wxMSW and wxGTK currently.
60 if __name__
== '__main__':
63 run
.main(['', os
.path
.basename(sys
.argv
[0])])