| 1 | |
| 2 | from wxPython.wx import * |
| 3 | |
| 4 | #--------------------------------------------------------------------------- |
| 5 | |
| 6 | class TestComboBox(wxPanel): |
| 7 | def OnSetFocus(self, evt): |
| 8 | print "OnSetFocus" |
| 9 | evt.Skip() |
| 10 | def OnKillFocus(self, evt): |
| 11 | print "OnKillFocus" |
| 12 | evt.Skip() |
| 13 | |
| 14 | def __init__(self, parent, log): |
| 15 | self.log = log |
| 16 | wxPanel.__init__(self, parent, -1) |
| 17 | |
| 18 | sampleList = ['zero', 'one', 'two', 'three', 'four', 'five', |
| 19 | 'six', 'seven', 'eight'] |
| 20 | |
| 21 | wxStaticText(self, -1, "This example uses the wxComboBox control.", |
| 22 | wxPoint(8, 10)) |
| 23 | |
| 24 | wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(75, 18)) |
| 25 | cb = wxComboBox(self, 500, "default value", wxPoint(80, 50), wxSize(95, -1), |
| 26 | sampleList, wxCB_DROPDOWN) |
| 27 | EVT_COMBOBOX(self, 500, self.EvtComboBox) |
| 28 | EVT_TEXT(self, 500, self.EvtText) |
| 29 | EVT_SET_FOCUS(cb, self.OnSetFocus) |
| 30 | EVT_KILL_FOCUS(cb, self.OnKillFocus) |
| 31 | |
| 32 | cb.Append("foo") |
| 33 | |
| 34 | wxComboBox(self, 501, "default value", wxPoint(80, 80), wxSize(95, -1), |
| 35 | sampleList, wxCB_SIMPLE) |
| 36 | EVT_COMBOBOX(self, 501, self.EvtComboBox) |
| 37 | EVT_TEXT(self, 501, self.EvtText) |
| 38 | |
| 39 | |
| 40 | def EvtComboBox(self, event): |
| 41 | self.log.WriteText('EvtComboBox: %s\n' % event.GetString()) |
| 42 | |
| 43 | def EvtText(self, event): |
| 44 | self.log.WriteText('EvtText: %s\n' % event.GetString()) |
| 45 | |
| 46 | #--------------------------------------------------------------------------- |
| 47 | |
| 48 | def runTest(frame, nb, log): |
| 49 | win = TestComboBox(nb, log) |
| 50 | return win |
| 51 | |
| 52 | #--------------------------------------------------------------------------- |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | overview = """\ |
| 66 | 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. |
| 67 | |
| 68 | """ |