]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxCheckListBox.py
2 from wxPython
.wx
import *
4 #----------------------------------------------------------------------
6 class TestPanel(wxPanel
):
7 def __init__(self
, parent
, log
):
8 wxPanel
.__init
__(self
, parent
, -1)
11 sampleList
= ['zero', 'one', 'two', 'three', 'four', 'five',
12 'six', 'seven', 'eight', 'nine', 'ten', 'eleven',
13 'twelve', 'thirteen', 'fourteen']
15 wxStaticText(self
, -1, "This example uses the wxCheckListBox control.",
18 lb
= wxCheckListBox(self
, 60, (80, 50), (80, 120),
20 EVT_LISTBOX(self
, 60, self
.EvtListBox
)
21 EVT_LISTBOX_DCLICK(self
, 60, self
.EvtListBoxDClick
)
25 pos
= lb
.GetPosition().x
+ lb
.GetSize().width
+ 25
26 btn
= wxButton(self
, -1, "Test SetString", (pos
, 50))
27 EVT_BUTTON(self
, btn
.GetId(), self
.OnTestButton
)
29 EVT_RIGHT_UP(self
, self
.OnDoPopup
)
32 def EvtListBox(self
, event
):
33 self
.log
.WriteText('EvtListBox: %s\n' % event
.GetString())
35 def EvtListBoxDClick(self
, event
):
36 self
.log
.WriteText('EvtListBoxDClick:\n')
38 def OnTestButton(self
, evt
):
39 self
.lb
.SetString(4, "FUBAR")
42 def OnDoPopup(self
, evt
):
44 # Make this first item bold
45 item
= wxMenuItem(menu
, wxNewId(), "If supported, this is bold")
46 df
= wxSystemSettings_GetSystemFont(wxSYS_DEFAULT_GUI_FONT
)
47 nf
= wxFont(df
.GetPointSize(), df
.GetFamily(), df
.GetStyle(), wxBOLD
,
48 False, df
.GetFaceName())
52 menu
.AppendItem(wxMenuItem(menu
, wxNewId(), "Normal Item &1"))
53 menu
.AppendItem(wxMenuItem(menu
, wxNewId(), "Normal Item &2"))
54 menu
.AppendItem(wxMenuItem(menu
, wxNewId(), "Normal Item &3"))
55 menu
.AppendItem(wxMenuItem(menu
, wxNewId(), "Normal Item &4"))
57 self
.PopupMenu(menu
, evt
.GetPosition())
62 #----------------------------------------------------------------------
64 def runTest(frame
, nb
, log
):
65 win
= TestPanel(nb
, log
)
68 #----------------------------------------------------------------------
80 if __name__
== '__main__':
83 run
.main(['', os
.path
.basename(sys
.argv
[0])])