]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/ComboTreeBox.py
Updated build files.
[wxWidgets.git] / wxPython / demo / ComboTreeBox.py
CommitLineData
4f708f05
RD
1import wx
2from wx.lib.combotreebox import ComboTreeBox
3
4
5#---------------------------------------------------------------------------
6
7
8class TestComboTreeBox(wx.Panel):
9 def __init__(self, parent, log):
10 super(TestComboTreeBox, self).__init__(parent)
11 self.log = log
12 panelSizer = wx.FlexGridSizer(2, 2)
13 panelSizer.AddGrowableCol(1)
14 for style, labelText in [(0, 'Default style:'),
15 (wx.CB_READONLY, 'Read-only style:')]:
16 label = wx.StaticText(self, label=labelText)
17 panelSizer.Add(label, flag=wx.ALL|wx.ALIGN_CENTER_VERTICAL,
18 border=5)
19 comboBox = self._createComboTreeBox(style)
20 panelSizer.Add(comboBox, flag=wx.EXPAND|wx.ALL, border=5)
21 self.SetSizerAndFit(panelSizer)
22
23 def _createComboTreeBox(self, style):
24 comboBox = ComboTreeBox(self, style=style)
25 self._bindEventHandlers(comboBox)
26 for i in range(5):
27 child = comboBox.Append('Item %d'%i)
28 for j in range(5):
29 grandChild = comboBox.Append('Item %d.%d'%(i,j), child)
30 for k in range(5):
31 comboBox.Append('Item %d.%d.%d'%(i,j, k), grandChild)
32 return comboBox
33
34 def _bindEventHandlers(self, comboBox):
35 for eventType, handler in [(wx.EVT_COMBOBOX, self.OnItemSelected),
36 (wx.EVT_TEXT, self.OnItemEntered)]:
37 comboBox.Bind(eventType, handler)
38
39 def OnItemSelected(self, event):
40 self.log.WriteText('You selected: %s\n'%event.GetString())
41 event.Skip()
42
43 def OnItemEntered(self, event):
44 self.log.WriteText('You entered: %s\n'%event.GetString())
45 event.Skip()
46
47
48#---------------------------------------------------------------------------
49
50
51def runTest(frame, nb, log):
52 win = TestComboTreeBox(nb, log)
53 return win
54
55
56#---------------------------------------------------------------------------
57
58
59overview = wx.lib.combotreebox.__doc__
60
61
62#---------------------------------------------------------------------------
63
64
65if __name__ == '__main__':
66 import sys, os
67 import run
68 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
69