From 167ad3b2954307e77795f9b8bf7dbf940b73e10d Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 1 Sep 2004 19:23:33 +0000 Subject: [PATCH] Demo the 3-state checkbox and also right-alignment git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28992 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/demo/CheckBox.py | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/wxPython/demo/CheckBox.py b/wxPython/demo/CheckBox.py index e4bc135066..c54edafefc 100644 --- a/wxPython/demo/CheckBox.py +++ b/wxPython/demo/CheckBox.py @@ -8,19 +8,46 @@ class TestCheckBox(wx.Panel): self.log = log wx.Panel.__init__(self, parent, -1) - wx.StaticText(self, -1, "This example uses the wxCheckBox control.", (10, 10)) + st = wx.StaticText(self, -1, "This example demonstrates the wx.CheckBox control.")#, (10, 10)) - 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) + 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) cb2.SetValue(True) - cb3 = wx.CheckBox(self, -1, " Pears", (65, 80), (150, 20), wx.NO_BORDER) + 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) + self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb1) self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb2) self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb3) + 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) + def EvtCheckBox(self, event): - self.log.WriteText('EvtCheckBox: %d\n' % event.IsChecked()) + self.log.write('EvtCheckBox: %d\n' % event.IsChecked()) + cb = event.GetEventObject() + if cb.Is3State(): + self.log.write("\t3StateValue: %s\n" % cb.Get3StateValue()) + #--------------------------------------------------------------------------- -- 2.45.2