From 982d1607826ec0e590146ff40b1dd7068296f004 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 2 Aug 2004 22:09:39 +0000 Subject: [PATCH] updated sample git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28592 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/demo/CheckListBox.py | 39 +++++++++-------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/wxPython/demo/CheckListBox.py b/wxPython/demo/CheckListBox.py index bfc4d40a43..4b64f42075 100644 --- a/wxPython/demo/CheckListBox.py +++ b/wxPython/demo/CheckListBox.py @@ -16,49 +16,30 @@ class TestPanel(wx.Panel): lb = wx.CheckListBox(self, -1, (80, 50), wx.DefaultSize, sampleList) self.Bind(wx.EVT_LISTBOX, self.EvtListBox, lb) - self.Bind(wx.EVT_LISTBOX_DCLICK, self.EvtListBoxDClick, lb) + self.Bind(wx.EVT_CHECKLISTBOX, self.EvtCheckListBox, lb) lb.SetSelection(0) self.lb = lb pos = lb.GetPosition().x + lb.GetSize().width + 25 btn = wx.Button(self, -1, "Test SetString", (pos, 50)) self.Bind(wx.EVT_BUTTON, self.OnTestButton, btn) - self.Bind(wx.EVT_RIGHT_UP, self.OnDoPopup) def EvtListBox(self, event): self.log.WriteText('EvtListBox: %s\n' % event.GetString()) - def EvtListBoxDClick(self, event): - self.log.WriteText('EvtListBoxDClick:\n') + def EvtCheckListBox(self, event): + index = event.GetSelection() + label = self.lb.GetString(index) + status = 'un' + if self.lb.IsChecked(index): + status = '' + self.log.WriteText('Box %s is %schecked \n' % (label, status)) + self.lb.SetSelection(index) # so that (un)checking also selects (moves the highlight) + def OnTestButton(self, evt): self.lb.SetString(4, "FUBAR") - - def OnDoPopup(self, evt): - menu = wx.Menu() - # Make this first item bold - item = wx.MenuItem(menu, wx.NewId(), "If supported, this is bold") - df = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) - - nf = wx.Font( - df.GetPointSize(), df.GetFamily(), df.GetStyle(), - wx.BOLD, False, df.GetFaceName() - ) - - item.SetFont(nf) - menu.AppendItem(item) - - menu.AppendItem(wx.MenuItem(menu, wx.NewId(), "Normal Item &1")) - menu.AppendItem(wx.MenuItem(menu, wx.NewId(), "Normal Item &2")) - menu.AppendItem(wx.MenuItem(menu, wx.NewId(), "Normal Item &3")) - menu.AppendItem(wx.MenuItem(menu, wx.NewId(), "Normal Item &4")) - - self.PopupMenu(menu, evt.GetPosition()) - menu.Destroy() - evt.Skip() - - #---------------------------------------------------------------------- def runTest(frame, nb, log): -- 2.45.2