2 from wxPython
.wx
import *
4 #---------------------------------------------------------------------------
6 class TestComboBox(wxPanel
):
7 def __init__(self
, parent
, log
):
9 wxPanel
.__init
__(self
, parent
, -1)
11 sampleList
= ['zero', 'one', 'two', 'three', 'four', 'five',
12 'six', 'seven', 'eight']
14 wxStaticText(self
, -1, "This example uses the wxComboBox control.",
17 wxStaticText(self
, -1, "Select one:", wxPoint(15, 50), wxSize(75, 18))
18 wxComboBox(self
, 500, "default value", wxPoint(80, 50), wxSize(95, -1),
19 sampleList
, wxCB_DROPDOWN
)
20 EVT_COMBOBOX(self
, 500, self
.EvtComboBox
)
21 EVT_TEXT(self
, 500, self
.EvtText
)
24 def EvtComboBox(self
, event
):
25 self
.log
.WriteText('EvtComboBox: %s\n' % event
.GetString())
27 def EvtText(self
, event
):
28 self
.log
.WriteText('EvtText: %s\n' % event
.GetString())
30 #---------------------------------------------------------------------------
32 def runTest(frame
, nb
, log
):
33 win
= TestComboBox(nb
, log
)
36 #---------------------------------------------------------------------------
50 A combobox is like a combination of an edit control and a listbox. It can be displayed as static list with editable or read-only text field; or a drop-down list with text field; or a drop-down list without a text field.
52 A combobox permits a single selection only. Combobox items are numbered from zero.
55 -----------------------
59 wxComboBox(wxWindow* parent, wxWindowID id, const wxString& value = "", const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, int n, const wxString choices[], long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = "comboBox")
61 Constructor, creating and showing a combobox.
66 parent = Parent window. Must not be NULL.
68 id = Window identifier. A value of -1 indicates a default value.
70 pos = Window position.
72 size = Window size. If the default size (-1, -1) is specified then the window is sized appropriately.
74 n = Number of strings with which to initialise the control.
76 choices = An array of strings with which to initialise the control.
78 style = Window style. See wxComboBox.
80 validator = Window validator.