]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/CheckListBox.py
4 #----------------------------------------------------------------------
6 class TestPanel(wx
.Panel
):
7 def __init__(self
, parent
, log
):
8 wx
.Panel
.__init
__(self
, parent
, -1)
11 sampleList
= ['zero', 'one', 'two', 'three', 'four', 'five',
12 'six', 'seven', 'eight', 'nine', 'ten', 'eleven',
13 'twelve', 'thirteen', 'fourteen']
15 wx
.StaticText(self
, -1, "This example uses the wxCheckListBox control.", (45, 15))
17 lb
= wx
.CheckListBox(self
, -1, (80, 50), wx
.DefaultSize
, sampleList
)
18 self
.Bind(wx
.EVT_LISTBOX
, self
.EvtListBox
, lb
)
19 self
.Bind(wx
.EVT_LISTBOX_DCLICK
, self
.EvtListBoxDClick
, lb
)
23 pos
= lb
.GetPosition().x
+ lb
.GetSize().width
+ 25
24 btn
= wx
.Button(self
, -1, "Test SetString", (pos
, 50))
25 self
.Bind(wx
.EVT_BUTTON
, self
.OnTestButton
, btn
)
26 self
.Bind(wx
.EVT_RIGHT_UP
, self
.OnDoPopup
)
28 def EvtListBox(self
, event
):
29 self
.log
.WriteText('EvtListBox: %s\n' % event
.GetString())
31 def EvtListBoxDClick(self
, event
):
32 self
.log
.WriteText('EvtListBoxDClick:\n')
34 def OnTestButton(self
, evt
):
35 self
.lb
.SetString(4, "FUBAR")
38 def OnDoPopup(self
, evt
):
40 # Make this first item bold
41 item
= wx
.MenuItem(menu
, wx
.NewId(), "If supported, this is bold")
42 df
= wx
.SystemSettings
.GetFont(wx
.SYS_DEFAULT_GUI_FONT
)
45 df
.GetPointSize(), df
.GetFamily(), df
.GetStyle(),
46 wx
.BOLD
, False, df
.GetFaceName()
52 menu
.AppendItem(wx
.MenuItem(menu
, wx
.NewId(), "Normal Item &1"))
53 menu
.AppendItem(wx
.MenuItem(menu
, wx
.NewId(), "Normal Item &2"))
54 menu
.AppendItem(wx
.MenuItem(menu
, wx
.NewId(), "Normal Item &3"))
55 menu
.AppendItem(wx
.MenuItem(menu
, wx
.NewId(), "Normal Item &4"))
57 self
.PopupMenu(menu
, evt
.GetPosition())
62 #----------------------------------------------------------------------
64 def runTest(frame
, nb
, log
):
65 win
= TestPanel(nb
, log
)
68 #----------------------------------------------------------------------
72 A checklistbox is like a Listbox, but allows items to be checked or unchecked rather
73 than relying on extended selection (e.g. shift-select) to select multiple items in
76 This class is currently implemented under Windows and GTK.
78 This demo shows the basic CheckListBox and how to use the SetString method to change
83 if __name__
== '__main__':
86 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])