2001-05-06 05:03:24 +00:00
|
|
|
|
|
|
|
from wxPython.wx import *
|
|
|
|
|
2002-08-13 23:59:08 +00:00
|
|
|
haveToggleBtn = 1
|
|
|
|
try:
|
|
|
|
wxToggleButton
|
|
|
|
except NameError:
|
|
|
|
haveToggleBtn = 0
|
|
|
|
|
2001-05-06 05:03:24 +00:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class TestPanel(wxPanel):
|
|
|
|
def __init__(self, parent, log):
|
|
|
|
wxPanel.__init__(self, parent, -1)
|
|
|
|
self.log = log
|
|
|
|
panel = wxPanel(self, -1)
|
|
|
|
buttons = wxBoxSizer(wxHORIZONTAL)
|
2003-03-25 06:35:27 +00:00
|
|
|
for word in "These are toggle buttons".split():
|
2001-05-06 05:03:24 +00:00
|
|
|
b = wxToggleButton(panel, -1, word)
|
|
|
|
EVT_TOGGLEBUTTON(self, b.GetId(), self.OnToggle)
|
|
|
|
buttons.Add(b, flag=wxALL, border=5)
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
panel.SetAutoLayout(True)
|
2001-05-06 05:03:24 +00:00
|
|
|
panel.SetSizer(buttons)
|
|
|
|
buttons.Fit(panel)
|
|
|
|
panel.Move((50,50))
|
|
|
|
|
|
|
|
def OnToggle(self, evt):
|
|
|
|
self.log.write("Button %d toggled\n" % evt.GetId())
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
2002-08-13 23:59:08 +00:00
|
|
|
if haveToggleBtn:
|
|
|
|
win = TestPanel(nb, log)
|
|
|
|
return win
|
|
|
|
else:
|
|
|
|
dlg = wxMessageDialog(frame, 'wxToggleButton is not available on this platform.',
|
|
|
|
'Sorry', wxOK | wxICON_INFORMATION)
|
|
|
|
dlg.ShowModal()
|
|
|
|
dlg.Destroy()
|
|
|
|
|
|
|
|
|
2001-05-06 05:03:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
overview = """\
|
|
|
|
"""
|
2003-07-02 23:13:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys,os
|
|
|
|
import run
|
|
|
|
run.main(['', os.path.basename(sys.argv[0])])
|