Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / lib / python2.4 / site-packages / Pmw / Pmw_1_2 / lib / PmwComboBoxDialog.py
CommitLineData
920dae64
AT
1# Not Based on iwidgets version.
2
3import Pmw
4
5class ComboBoxDialog(Pmw.Dialog):
6 # Dialog window with simple combobox.
7
8 # Dialog window displaying a list and entry field and requesting
9 # the user to make a selection or enter a value
10
11 def __init__(self, parent = None, **kw):
12 # Define the megawidget options.
13 INITOPT = Pmw.INITOPT
14 optiondefs = (
15 ('borderx', 10, INITOPT),
16 ('bordery', 10, INITOPT),
17 )
18 self.defineoptions(kw, optiondefs)
19
20 # Initialise the base class (after defining the options).
21 Pmw.Dialog.__init__(self, parent)
22
23 # Create the components.
24 interior = self.interior()
25
26 aliases = (
27 ('listbox', 'combobox_listbox'),
28 ('scrolledlist', 'combobox_scrolledlist'),
29 ('entry', 'combobox_entry'),
30 ('label', 'combobox_label'),
31 )
32 self._combobox = self.createcomponent('combobox',
33 aliases, None,
34 Pmw.ComboBox, (interior,),
35 scrolledlist_dblclickcommand = self.invoke,
36 dropdown = 0,
37 )
38 self._combobox.pack(side='top', expand='true', fill='both',
39 padx = self['borderx'], pady = self['bordery'])
40
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)
46
47 # Check keywords and initialise options.
48 self.initialiseoptions()
49
50 # Need to explicitly forward this to override the stupid
51 # (grid_)size method inherited from Tkinter.Toplevel.Grid.
52 def size(self):
53 return self._combobox.size()
54
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)
59
60Pmw.forwardmethods(ComboBoxDialog, Pmw.ComboBox, '_combobox')