]>
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)) | |
19 | lb = wxListBox(self, 60, wxPoint(80, 50), wxSize(80, 120), | |
20 | sampleList, wxLB_SINGLE) | |
21 | EVT_LISTBOX(self, 60, self.EvtListBox) | |
22 | EVT_LISTBOX_DCLICK(self, 60, self.EvtListBoxDClick) | |
23 | lb.SetSelection(0) | |
24 | ||
25 | ||
26 | wxStaticText(self, -1, "Select many:", wxPoint(200, 50), wxSize(65, 18)) | |
27 | self.lb = wxListBox(self, 70, wxPoint(280, 50), wxSize(80, 120), | |
28 | sampleList, wxLB_EXTENDED) | |
29 | EVT_LISTBOX(self, 70, self.EvtMultiListBox) | |
30 | EVT_LISTBOX_DCLICK(self, 70, self.EvtListBoxDClick) | |
31 | self.lb.SetSelection(0) | |
32 | ||
33 | ||
34 | def EvtListBox(self, event): | |
35 | self.log.WriteText('EvtListBox: %s\n' % event.GetString()) | |
36 | ||
37 | def EvtListBoxDClick(self, event): | |
38 | self.log.WriteText('EvtListBoxDClick:\n') | |
39 | ||
40 | def EvtMultiListBox(self, event): | |
41 | self.log.WriteText('EvtMultiListBox: %s\n' % str(self.lb.GetSelections())) | |
42 | ||
43 | ||
44 | #--------------------------------------------------------------------------- | |
45 | ||
46 | def runTest(frame, nb, log): | |
47 | win = TestListBox(nb, log) | |
48 | return win | |
49 | ||
50 | #--------------------------------------------------------------------------- | |
51 | ||
52 | ||
53 | ||
54 | ||
55 | ||
56 | ||
57 | ||
58 | ||
59 | ||
60 | ||
61 | ||
62 | ||
63 | ||
64 | ||
65 | overview = """\ | |
66 | 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). | |
67 | ||
68 | List box elements are numbered from zero. | |
69 | ||
70 | wxListBox() | |
71 | --------------------- | |
72 | ||
73 | Default constructor. | |
74 | ||
75 | 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") | |
76 | ||
77 | Constructor, creating and showing a list box. | |
78 | ||
79 | Parameters | |
80 | ------------------- | |
81 | ||
82 | parent = Parent window. Must not be NULL. | |
83 | ||
84 | id = Window identifier. A value of -1 indicates a default value. | |
85 | ||
86 | pos = Window position. | |
87 | ||
88 | size = Window size. If the default size (-1, -1) is specified then the window is sized appropriately. | |
89 | ||
90 | n = Number of strings with which to initialise the control. | |
91 | ||
92 | choices = An array of strings with which to initialise the control. | |
93 | ||
94 | style = Window style. See wxListBox. | |
95 | ||
96 | validator = Window validator. | |
97 | ||
98 | name = Window name. | |
99 | """ |