1 # Based on iwidgets2.2.0/promptdialog.itk code.
5 # A Dialog with an entryfield
7 class PromptDialog(Pmw.Dialog):
8 def __init__(self, parent = None, **kw):
9 # Define the megawidget options.
12 ('borderx', 20, INITOPT),
13 ('bordery', 20, INITOPT),
15 self.defineoptions(kw, optiondefs)
17 # Initialise the base class (after defining the options).
18 Pmw.Dialog.__init__(self, parent)
20 # Create the components.
21 interior = self.interior()
23 ('entry', 'entryfield_entry'),
24 ('label', 'entryfield_label'),
26 self._promptDialogEntry = self.createcomponent('entryfield',
28 Pmw.EntryField, (interior,))
29 self._promptDialogEntry.pack(fill='x', expand=1,
30 padx = self['borderx'], pady = self['bordery'])
32 if not kw.has_key('activatecommand'):
33 # Whenever this dialog is activated, set the focus to the
34 # EntryField's entry widget.
35 tkentry = self.component('entry')
36 self.configure(activatecommand = tkentry.focus_set)
38 # Check keywords and initialise options.
39 self.initialiseoptions()
41 # Supply aliases to some of the entry component methods.
42 def insertentry(self, index, text):
43 self._promptDialogEntry.insert(index, text)
45 def deleteentry(self, first, last=None):
46 self._promptDialogEntry.delete(first, last)
48 def indexentry(self, index):
49 return self._promptDialogEntry.index(index)
51 Pmw.forwardmethods(PromptDialog, Pmw.EntryField, '_promptDialogEntry')