1 # Not Based on iwidgets version.
5 class SelectionDialog(Pmw.Dialog):
6 # Dialog window with selection list.
8 # Dialog window displaying a list and requesting the user to
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()
26 ('listbox', 'scrolledlist_listbox'),
27 ('label', 'scrolledlist_label'),
29 self._list = self.createcomponent('scrolledlist',
31 Pmw.ScrolledListBox, (interior,),
32 dblclickcommand = self.invoke)
33 self._list.pack(side='top', expand='true', fill='both',
34 padx = self['borderx'], pady = self['bordery'])
36 if not kw.has_key('activatecommand'):
37 # Whenever this dialog is activated, set the focus to the
38 # ScrolledListBox's listbox widget.
39 listbox = self.component('listbox')
40 self.configure(activatecommand = listbox.focus_set)
42 # Check keywords and initialise options.
43 self.initialiseoptions()
45 # Need to explicitly forward this to override the stupid
46 # (grid_)size method inherited from Tkinter.Toplevel.Grid.
48 return self.component('listbox').size()
50 # Need to explicitly forward this to override the stupid
51 # (grid_)bbox method inherited from Tkinter.Toplevel.Grid.
52 def bbox(self, index):
53 return self.component('listbox').size(index)
55 Pmw.forwardmethods(SelectionDialog, Pmw.ScrolledListBox, '_list')