]> SALOME platform Git repositories - tools/eficas.git/blob - Pmw/Pmw_1_2/lib/PmwSelectionDialog.py
Salome HOME
Modif V6_4_°
[tools/eficas.git] / Pmw / Pmw_1_2 / lib / PmwSelectionDialog.py
1 # Not Based on iwidgets version.
2
3 import Pmw
4
5 class SelectionDialog(Pmw.Dialog):
6     # Dialog window with selection list.
7     
8     # Dialog window displaying a list and requesting the user to
9     # select one.
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         aliases = (
26             ('listbox', 'scrolledlist_listbox'),
27             ('label', 'scrolledlist_label'),
28         )
29         self._list = self.createcomponent('scrolledlist',
30                 aliases, None,
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'])
35
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)
41
42         # Check keywords and initialise options.
43         self.initialiseoptions()
44
45     # Need to explicitly forward this to override the stupid
46     # (grid_)size method inherited from Tkinter.Toplevel.Grid.
47     def size(self):
48         return self.component('listbox').size()
49
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)
54
55 Pmw.forwardmethods(SelectionDialog, Pmw.ScrolledListBox, '_list')