]>
Commit | Line | Data |
---|---|---|
8fa876ca RD |
1 | # 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) |
2 | # | |
3 | # o Updated for wx namespace | |
4 | # o Why is there a popup menu in this demo? | |
5 | # | |
cf694132 | 6 | |
8fa876ca | 7 | import wx |
cf694132 RD |
8 | |
9 | #---------------------------------------------------------------------- | |
10 | ||
8fa876ca | 11 | class TestPanel(wx.Panel): |
cf694132 | 12 | def __init__(self, parent, log): |
8fa876ca | 13 | wx.Panel.__init__(self, parent, -1) |
cf694132 RD |
14 | self.log = log |
15 | ||
16 | sampleList = ['zero', 'one', 'two', 'three', 'four', 'five', | |
17 | 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', | |
18 | 'twelve', 'thirteen', 'fourteen'] | |
19 | ||
8fa876ca | 20 | wx.StaticText(self, -1, "This example uses the wxCheckListBox control.", (45, 15)) |
cf694132 | 21 | |
8fa876ca RD |
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) | |
cf694132 | 25 | lb.SetSelection(0) |
be43cc44 RD |
26 | self.lb = lb |
27 | ||
1e4a197e | 28 | pos = lb.GetPosition().x + lb.GetSize().width + 25 |
8fa876ca RD |
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) | |
cf694132 RD |
32 | |
33 | def EvtListBox(self, event): | |
34 | self.log.WriteText('EvtListBox: %s\n' % event.GetString()) | |
35 | ||
36 | def EvtListBoxDClick(self, event): | |
37 | self.log.WriteText('EvtListBoxDClick:\n') | |
38 | ||
be43cc44 RD |
39 | def OnTestButton(self, evt): |
40 | self.lb.SetString(4, "FUBAR") | |
41 | ||
42 | ||
25832b3f | 43 | def OnDoPopup(self, evt): |
8fa876ca | 44 | menu = wx.Menu() |
25832b3f | 45 | # Make this first item bold |
8fa876ca RD |
46 | item = wx.MenuItem(menu, wx.NewId(), "If supported, this is bold") |
47 | df = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) | |
48 | ||
49 | nf = wx.Font( | |
50 | df.GetPointSize(), df.GetFamily(), df.GetStyle(), | |
51 | wx.BOLD, False, df.GetFaceName() | |
52 | ) | |
53 | ||
25832b3f RD |
54 | item.SetFont(nf) |
55 | menu.AppendItem(item) | |
56 | ||
8fa876ca RD |
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")) | |
25832b3f RD |
61 | |
62 | self.PopupMenu(menu, evt.GetPosition()) | |
63 | menu.Destroy() | |
64 | evt.Skip() | |
cf694132 RD |
65 | |
66 | ||
67 | #---------------------------------------------------------------------- | |
68 | ||
69 | def runTest(frame, nb, log): | |
70 | win = TestPanel(nb, log) | |
71 | return win | |
72 | ||
73 | #---------------------------------------------------------------------- | |
74 | ||
75 | ||
1fded56b | 76 | overview = """\ |
8fa876ca RD |
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 | |
79 | the list. | |
cf694132 | 80 | |
8fa876ca | 81 | This class is currently implemented under Windows and GTK. |
cf694132 | 82 | |
8fa876ca RD |
83 | This demo shows the basic CheckListBox and how to use the SetString method to change |
84 | labels dynamically. | |
85 | """ | |
cf694132 RD |
86 | |
87 | ||
1fded56b RD |
88 | if __name__ == '__main__': |
89 | import sys,os | |
90 | import run | |
91 | run.main(['', os.path.basename(sys.argv[0])]) | |
cf694132 | 92 |