]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxCheckListBox.py
Added compatibility file
[wxWidgets.git] / wxPython / demo / wxCheckListBox.py
1
2 from wxPython.wx import *
3
4 #----------------------------------------------------------------------
5
6 class TestPanel(wxPanel):
7 def __init__(self, parent, log):
8 wxPanel.__init__(self, parent, -1)
9 self.log = log
10
11 sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
12 'six', 'seven', 'eight', 'nine', 'ten', 'eleven',
13 'twelve', 'thirteen', 'fourteen']
14
15 wxStaticText(self, -1, "This example uses the wxCheckListBox control.",
16 (45, 15))
17
18 lb = wxCheckListBox(self, 60, (80, 50), (80, 120),
19 sampleList)
20 EVT_LISTBOX(self, 60, self.EvtListBox)
21 EVT_LISTBOX_DCLICK(self, 60, self.EvtListBoxDClick)
22 lb.SetSelection(0)
23 self.lb = lb
24
25 btn = wxButton(self, -1, "Test SetString", (180, 50))
26 EVT_BUTTON(self, btn.GetId(), self.OnTestButton)
27
28 EVT_RIGHT_UP(self, self.OnDoPopup)
29
30
31 def EvtListBox(self, event):
32 self.log.WriteText('EvtListBox: %s\n' % event.GetString())
33
34 def EvtListBoxDClick(self, event):
35 self.log.WriteText('EvtListBoxDClick:\n')
36
37 def OnTestButton(self, evt):
38 self.lb.SetString(4, "FUBAR")
39
40
41 def OnDoPopup(self, evt):
42 menu = wxMenu()
43 # Make this first item bold
44 item = wxMenuItem(menu, wxNewId(), "If supported, this is bold")
45 df = wxSystemSettings_GetSystemFont(wxSYS_DEFAULT_GUI_FONT)
46 nf = wxFont(df.GetPointSize(), df.GetFamily(), df.GetStyle(), wxBOLD,
47 false, df.GetFaceName())
48 item.SetFont(nf)
49 menu.AppendItem(item)
50
51 menu.AppendItem(wxMenuItem(menu, wxNewId(), "Normal Item &1"))
52 menu.AppendItem(wxMenuItem(menu, wxNewId(), "Normal Item &2"))
53 menu.AppendItem(wxMenuItem(menu, wxNewId(), "Normal Item &3"))
54 menu.AppendItem(wxMenuItem(menu, wxNewId(), "Normal Item &4"))
55
56 self.PopupMenu(menu, evt.GetPosition())
57 menu.Destroy()
58 evt.Skip()
59
60
61 #----------------------------------------------------------------------
62
63 def runTest(frame, nb, log):
64 win = TestPanel(nb, log)
65 return win
66
67 #----------------------------------------------------------------------
68
69
70
71
72
73
74
75
76
77
78 overview = """\
79 """
80
81