]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxListBox.py
applied patch to uncover cells next to 0 automatically
[wxWidgets.git] / wxPython / demo / wxListBox.py
CommitLineData
cf694132
RD
1
2from wxPython.wx import *
3
4#---------------------------------------------------------------------------
5
6class TestListBox(wxPanel):
7 def __init__(self, parent, log):
8 self.log = log
9 wxPanel.__init__(self, parent, -1)
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 wxListBox control.",
16 wxPoint(45, 10))
17
18 wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(65, 18))
bb0054cd 19 self.lb1 = wxListBox(self, 60, wxPoint(80, 50), wxSize(80, 120),
cf694132
RD
20 sampleList, wxLB_SINGLE)
21 EVT_LISTBOX(self, 60, self.EvtListBox)
22 EVT_LISTBOX_DCLICK(self, 60, self.EvtListBoxDClick)
bb0054cd
RD
23 EVT_RIGHT_UP(self.lb1, self.EvtRightButton)
24 self.lb1.SetSelection(0)
cf694132
RD
25
26
27 wxStaticText(self, -1, "Select many:", wxPoint(200, 50), wxSize(65, 18))
bb0054cd 28 self.lb2 = wxListBox(self, 70, wxPoint(280, 50), wxSize(80, 120),
cf694132
RD
29 sampleList, wxLB_EXTENDED)
30 EVT_LISTBOX(self, 70, self.EvtMultiListBox)
31 EVT_LISTBOX_DCLICK(self, 70, self.EvtListBoxDClick)
bb0054cd 32 self.lb2.SetSelection(0)
cf694132
RD
33
34
35 def EvtListBox(self, event):
36 self.log.WriteText('EvtListBox: %s\n' % event.GetString())
37
38 def EvtListBoxDClick(self, event):
bb0054cd 39 self.log.WriteText('EvtListBoxDClick: %s\n' % self.lb1.GetSelection())
5d1bd859 40 self.lb1.Delete(self.lb1.GetSelection())
cf694132
RD
41
42 def EvtMultiListBox(self, event):
bb0054cd 43 self.log.WriteText('EvtMultiListBox: %s\n' % str(self.lb2.GetSelections()))
cf694132 44
bb0054cd
RD
45 def EvtRightButton(self, event):
46 self.log.WriteText('EvtRightButton: %s\n' % event.GetPosition())
cf694132
RD
47
48#---------------------------------------------------------------------------
49
50def runTest(frame, nb, log):
51 win = TestListBox(nb, log)
52 return win
53
54#---------------------------------------------------------------------------
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69overview = """\
70A listbox is used to select one or more of a list of strings. The strings are displayed in a scrolling box, with the selected string(s) marked in reverse video. A listbox can be single selection (if an item is selected, the previous selection is removed) or multiple selection (clicking an item toggles the item on or off independently of other selections).
71
72List box elements are numbered from zero.
73
74wxListBox()
75---------------------
76
77Default constructor.
78
79wxListBox(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, int n, const wxString choices[] = NULL, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = "listBox")
80
81Constructor, creating and showing a list box.
82
83Parameters
84-------------------
85
86parent = Parent window. Must not be NULL.
87
88id = Window identifier. A value of -1 indicates a default value.
89
90pos = Window position.
91
92size = Window size. If the default size (-1, -1) is specified then the window is sized appropriately.
93
94n = Number of strings with which to initialise the control.
95
96choices = An array of strings with which to initialise the control.
97
98style = Window style. See wxListBox.
99
100validator = Window validator.
101
102name = Window name.
103"""