]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/ToggleButton.py
   5 if wx
.Platform 
== "__WXX11__": 
   8 #---------------------------------------------------------------------- 
  10 class TestPanel(wx
.Panel
): 
  11     def __init__(self
, parent
, log
): 
  12         wx
.Panel
.__init
__(self
, parent
, -1) 
  14         panel 
= wx
.Panel(self
, -1) 
  15         buttons 
= wx
.BoxSizer(wx
.HORIZONTAL
) 
  17         for word 
in "These are toggle buttons".split(): 
  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) 
  22         panel
.SetAutoLayout(True) 
  23         panel
.SetSizer(buttons
) 
  27     def OnToggle(self
, evt
): 
  28         self
.log
.write("Button %d toggled\n" % evt
.GetId()) 
  30 #---------------------------------------------------------------------- 
  32 def runTest(frame
, nb
, log
): 
  34         win 
= TestPanel(nb
, log
) 
  37         from Main 
import MessagePanel
 
  38         win 
= MessagePanel(nb
, 'wx.ToggleButton is not available on this platform.', 
  39                            'Sorry', wx
.ICON_WARNING
) 
  43 #---------------------------------------------------------------------- 
  47 wx.ToggleButton is a button that stays pressed when clicked by the user.  
  48 In other words, it is similar to wxCheckBox in functionality but looks like a  
  51 This class is only available under wxMSW and wxGTK currently. 
  57 if __name__ 
== '__main__': 
  60     run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])