1 # Not Based on iwidgets version.
5 class ComboBoxDialog(Pmw.Dialog):
6 # Dialog window with simple combobox.
8 # Dialog window displaying a list and entry field and requesting
9 # the user to make a selection or enter a value
11 def __init__(self, parent = None, **kw):
12 # Define the megawidget options.
15 ('borderx', 10, INITOPT),
16 ('bordery', 10, INITOPT),
18 self.defineoptions(kw, optiondefs)
20 # Initialise the base class (after defining the options).
21 Pmw.Dialog.__init__(self, parent)
23 # Create the components.
24 interior = self.interior()
27 ('listbox', 'combobox_listbox'),
28 ('scrolledlist', 'combobox_scrolledlist'),
29 ('entry', 'combobox_entry'),
30 ('label', 'combobox_label'),
32 self._combobox = self.createcomponent('combobox',
34 Pmw.ComboBox, (interior,),
35 scrolledlist_dblclickcommand = self.invoke,
38 self._combobox.pack(side='top', expand='true', fill='both',
39 padx = self['borderx'], pady = self['bordery'])
41 if not kw.has_key('activatecommand'):
42 # Whenever this dialog is activated, set the focus to the
43 # ComboBox's listbox widget.
44 listbox = self.component('listbox')
45 self.configure(activatecommand = listbox.focus_set)
47 # Check keywords and initialise options.
48 self.initialiseoptions()
50 # Need to explicitly forward this to override the stupid
51 # (grid_)size method inherited from Tkinter.Toplevel.Grid.
53 return self._combobox.size()
55 # Need to explicitly forward this to override the stupid
56 # (grid_)bbox method inherited from Tkinter.Toplevel.Grid.
57 def bbox(self, index):
58 return self._combobox.bbox(index)
60 Pmw.forwardmethods(ComboBoxDialog, Pmw.ComboBox, '_combobox')