1999-04-29 23:29:54 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
import wx
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
class TestCheckBox(wx.Panel):
|
1999-04-29 23:29:54 -04:00
|
|
|
def __init__(self, parent, log):
|
|
|
|
self.log = log
|
2003-12-08 20:23:28 -05:00
|
|
|
wx.Panel.__init__(self, parent, -1)
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2004-09-01 15:23:33 -04:00
|
|
|
st = wx.StaticText(self, -1, "This example demonstrates the wx.CheckBox control.")#, (10, 10))
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2004-09-01 15:23:33 -04:00
|
|
|
cb1 = wx.CheckBox(self, -1, "Apples")#, (65, 40), (150, 20), wx.NO_BORDER)
|
|
|
|
cb2 = wx.CheckBox(self, -1, "Oranges")#, (65, 60), (150, 20), wx.NO_BORDER)
|
2003-03-25 01:35:27 -05:00
|
|
|
cb2.SetValue(True)
|
2004-09-01 15:23:33 -04:00
|
|
|
cb3 = wx.CheckBox(self, -1, "Pears")#, (65, 80), (150, 20), wx.NO_BORDER)
|
|
|
|
|
|
|
|
cb4 = wx.CheckBox(self, -1, "3-state checkbox",
|
|
|
|
style=wx.CHK_3STATE|wx.CHK_ALLOW_3RD_STATE_FOR_USER)
|
|
|
|
cb5 = wx.CheckBox(self, -1, "Align Right", style=wx.ALIGN_RIGHT)
|
|
|
|
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb1)
|
|
|
|
self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb2)
|
|
|
|
self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb3)
|
2004-09-01 15:23:33 -04:00
|
|
|
self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb4)
|
|
|
|
self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb5)
|
|
|
|
|
|
|
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
sizer.AddMany( [ cb1,
|
|
|
|
cb2,
|
|
|
|
cb3,
|
|
|
|
(20,20),
|
|
|
|
cb4,
|
|
|
|
(20,20),
|
|
|
|
cb5
|
|
|
|
])
|
|
|
|
|
|
|
|
border = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
border.Add(st, 0, wx.ALL, 15)
|
|
|
|
border.Add(sizer, 0, wx.LEFT, 50)
|
|
|
|
self.SetSizer(border)
|
|
|
|
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
def EvtCheckBox(self, event):
|
2004-09-01 15:23:33 -04:00
|
|
|
self.log.write('EvtCheckBox: %d\n' % event.IsChecked())
|
|
|
|
cb = event.GetEventObject()
|
|
|
|
if cb.Is3State():
|
|
|
|
self.log.write("\t3StateValue: %s\n" % cb.Get3StateValue())
|
|
|
|
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
|
|
|
win = TestCheckBox(nb, log)
|
|
|
|
return win
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
overview = """\
|
2004-01-12 22:17:17 -05:00
|
|
|
A checkbox is a labelled box which is either on (checkmark is visible) or off
|
|
|
|
(no checkmark).
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
"""
|
2003-07-02 19:13:10 -04:00
|
|
|
|
2004-01-12 22:17:17 -05:00
|
|
|
#---------------------------------------------------------------------------
|
2003-07-02 19:13:10 -04:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys,os
|
|
|
|
import run
|
2004-03-04 19:06:33 -05:00
|
|
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
2003-07-02 19:13:10 -04:00
|
|
|
|