]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/demo/wxCheckListBox.py
fix text scrolling in GTK2 (patch 703988)
[wxWidgets.git] / wxPython / demo / wxCheckListBox.py
... / ...
CommitLineData
1
2from wxPython.wx import *
3
4#----------------------------------------------------------------------
5
6class 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 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)
28
29 EVT_RIGHT_UP(self, self.OnDoPopup)
30
31
32 def EvtListBox(self, event):
33 self.log.WriteText('EvtListBox: %s\n' % event.GetString())
34
35 def EvtListBoxDClick(self, event):
36 self.log.WriteText('EvtListBoxDClick:\n')
37
38 def OnTestButton(self, evt):
39 self.lb.SetString(4, "FUBAR")
40
41
42 def OnDoPopup(self, evt):
43 menu = wxMenu()
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())
49 item.SetFont(nf)
50 menu.AppendItem(item)
51
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"))
56
57 self.PopupMenu(menu, evt.GetPosition())
58 menu.Destroy()
59 evt.Skip()
60
61
62#----------------------------------------------------------------------
63
64def runTest(frame, nb, log):
65 win = TestPanel(nb, log)
66 return win
67
68#----------------------------------------------------------------------
69
70
71
72
73overview = """\
74"""
75
76
77
78
79
80if __name__ == '__main__':
81 import sys,os
82 import run
83 run.main(['', os.path.basename(sys.argv[0])])
84