]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxComboBox.py
support Show() in wxFlexGridSizer (patch 737850)
[wxWidgets.git] / wxPython / demo / wxComboBox.py
CommitLineData
cf694132
RD
1from wxPython.wx import *
2
3#---------------------------------------------------------------------------
4
5class TestComboBox(wxPanel):
059a841c
RD
6 def OnSetFocus(self, evt):
7 print "OnSetFocus"
8 evt.Skip()
9 def OnKillFocus(self, evt):
10 print "OnKillFocus"
11 evt.Skip()
12
cf694132
RD
13 def __init__(self, parent, log):
14 self.log = log
15 wxPanel.__init__(self, parent, -1)
16
17 sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
18 'six', 'seven', 'eight']
19
20 wxStaticText(self, -1, "This example uses the wxComboBox control.",
21 wxPoint(8, 10))
22
23 wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(75, 18))
1e6796a0
RD
24 cb = wxComboBox(self, 500, "default value", wxPoint(90, 50), wxSize(95, -1),
25 sampleList, wxCB_DROPDOWN)#|wxTE_PROCESS_ENTER)
8bf5d46e 26 EVT_COMBOBOX(self, 500, self.EvtComboBox)
f6bcfd97 27 EVT_TEXT(self, 500, self.EvtText)
468c1af0 28 EVT_TEXT_ENTER(self, 500, self.EvtTextEnter)
059a841c
RD
29 EVT_SET_FOCUS(cb, self.OnSetFocus)
30 EVT_KILL_FOCUS(cb, self.OnKillFocus)
31
3bbeffe4 32 cb.Append("foo", "This is some client data for this item")
059a841c 33
1e6796a0 34 cb = wxComboBox(self, 501, "default value", wxPoint(90, 80), wxSize(95, -1),
68bc8549
RD
35 [], wxCB_SIMPLE)
36 for item in sampleList:
1e4a197e 37 cb.Append(item, item.upper())
059a841c
RD
38 EVT_COMBOBOX(self, 501, self.EvtComboBox)
39 EVT_TEXT(self, 501, self.EvtText)
cf694132
RD
40
41
3bbeffe4
RD
42 def EvtComboBox(self, evt):
43 cb = evt.GetEventObject()
44 data = cb.GetClientData(cb.GetSelection())
45 self.log.WriteText('EvtComboBox: %s\nClientData: %s\n' % (evt.GetString(), data))
cf694132 46
3bbeffe4
RD
47 def EvtText(self, evt):
48 self.log.WriteText('EvtText: %s\n' % evt.GetString())
f6bcfd97 49
468c1af0
RD
50 def EvtTextEnter(self, evt):
51 self.log.WriteText('EvtTextEnter: does this work?')
52
cf694132
RD
53#---------------------------------------------------------------------------
54
55def runTest(frame, nb, log):
56 win = TestComboBox(nb, log)
57 return win
58
59#---------------------------------------------------------------------------
60
61
62
63
64
65
66
1e6796a0
RD
67overview = """\
68A 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.
cf694132 69
1e6796a0 70"""
cf694132
RD
71
72
73
1e6796a0
RD
74if __name__ == '__main__':
75 import sys,os
76 import run
77 run.main(['', os.path.basename(sys.argv[0])])
cf694132 78