]>
Commit | Line | Data |
---|---|---|
cf694132 RD |
1 | |
2 | from wxPython.wx import * | |
3 | ||
4 | #--------------------------------------------------------------------------- | |
5 | ||
6 | class 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()) |
cf694132 RD |
40 | |
41 | def EvtMultiListBox(self, event): | |
bb0054cd | 42 | self.log.WriteText('EvtMultiListBox: %s\n' % str(self.lb2.GetSelections())) |
cf694132 | 43 | |
bb0054cd RD |
44 | def EvtRightButton(self, event): |
45 | self.log.WriteText('EvtRightButton: %s\n' % event.GetPosition()) | |
cf694132 RD |
46 | |
47 | #--------------------------------------------------------------------------- | |
48 | ||
49 | def runTest(frame, nb, log): | |
50 | win = TestListBox(nb, log) | |
51 | return win | |
52 | ||
53 | #--------------------------------------------------------------------------- | |
54 | ||
55 | ||
56 | ||
57 | ||
58 | ||
59 | ||
60 | ||
61 | ||
62 | ||
63 | ||
64 | ||
65 | ||
66 | ||
67 | ||
68 | overview = """\ | |
69 | A 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). | |
70 | ||
71 | List box elements are numbered from zero. | |
72 | ||
73 | wxListBox() | |
74 | --------------------- | |
75 | ||
76 | Default constructor. | |
77 | ||
78 | wxListBox(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") | |
79 | ||
80 | Constructor, creating and showing a list box. | |
81 | ||
82 | Parameters | |
83 | ------------------- | |
84 | ||
85 | parent = Parent window. Must not be NULL. | |
86 | ||
87 | id = Window identifier. A value of -1 indicates a default value. | |
88 | ||
89 | pos = Window position. | |
90 | ||
91 | size = Window size. If the default size (-1, -1) is specified then the window is sized appropriately. | |
92 | ||
93 | n = Number of strings with which to initialise the control. | |
94 | ||
95 | choices = An array of strings with which to initialise the control. | |
96 | ||
97 | style = Window style. See wxListBox. | |
98 | ||
99 | validator = Window validator. | |
100 | ||
101 | name = Window name. | |
102 | """ |