]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxCheckListBox.py
1 # 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net)
3 # o Updated for wx namespace
4 # o Why is there a popup menu in this demo?
9 #----------------------------------------------------------------------
11 class TestPanel(wx
.Panel
):
12 def __init__(self
, parent
, log
):
13 wx
.Panel
.__init
__(self
, parent
, -1)
16 sampleList
= ['zero', 'one', 'two', 'three', 'four', 'five',
17 'six', 'seven', 'eight', 'nine', 'ten', 'eleven',
18 'twelve', 'thirteen', 'fourteen']
20 wx
.StaticText(self
, -1, "This example uses the wxCheckListBox control.", (45, 15))
22 lb
= wx
.CheckListBox(self
, 60, (80, 50), (80, 120), sampleList
)
23 self
.Bind(wx
.EVT_LISTBOX
, self
.EvtListBox
, id=60)
24 self
.Bind(wx
.EVT_LISTBOX_DCLICK
, self
.EvtListBoxDClick
, id=60)
28 pos
= lb
.GetPosition().x
+ lb
.GetSize().width
+ 25
29 btn
= wx
.Button(self
, -1, "Test SetString", (pos
, 50))
30 self
.Bind(wx
.EVT_BUTTON
, self
.OnTestButton
, id=btn
.GetId())
31 self
.Bind(wx
.EVT_RIGHT_UP
, self
.OnDoPopup
)
33 def EvtListBox(self
, event
):
34 self
.log
.WriteText('EvtListBox: %s\n' % event
.GetString())
36 def EvtListBoxDClick(self
, event
):
37 self
.log
.WriteText('EvtListBoxDClick:\n')
39 def OnTestButton(self
, evt
):
40 self
.lb
.SetString(4, "FUBAR")
43 def OnDoPopup(self
, evt
):
45 # Make this first item bold
46 item
= wx
.MenuItem(menu
, wx
.NewId(), "If supported, this is bold")
47 df
= wx
.SystemSettings
.GetFont(wx
.SYS_DEFAULT_GUI_FONT
)
50 df
.GetPointSize(), df
.GetFamily(), df
.GetStyle(),
51 wx
.BOLD
, False, df
.GetFaceName()
57 menu
.AppendItem(wx
.MenuItem(menu
, wx
.NewId(), "Normal Item &1"))
58 menu
.AppendItem(wx
.MenuItem(menu
, wx
.NewId(), "Normal Item &2"))
59 menu
.AppendItem(wx
.MenuItem(menu
, wx
.NewId(), "Normal Item &3"))
60 menu
.AppendItem(wx
.MenuItem(menu
, wx
.NewId(), "Normal Item &4"))
62 self
.PopupMenu(menu
, evt
.GetPosition())
67 #----------------------------------------------------------------------
69 def runTest(frame
, nb
, log
):
70 win
= TestPanel(nb
, log
)
73 #----------------------------------------------------------------------
77 A checklistbox is like a Listbox, but allows items to be checked or unchecked rather
78 than relying on extended selection (e.g. shift-select) to select multiple items in
81 This class is currently implemented under Windows and GTK.
83 This demo shows the basic CheckListBox and how to use the SetString method to change
88 if __name__
== '__main__':
91 run
.main(['', os
.path
.basename(sys
.argv
[0])])