Setting Focus in Pmw.Dialog

Yael Raz yaelr at
Tue Sep 19 08:07:40 CEST 2000


A small but annoying problem with my first Python project:

I use Pmw.Dialog to prompt the user for some text.
The dialog is just what I need, but for some reason I can't set the initial
keyboard focus to the entry field.

The standard "askstring" dialog doesn't give me control over the edit field
size (that I can see), so I tried this:

 dialog = Pmw.Dialog( root,
       buttons = ( 'OK', ),
       buttonboxpos = S,
       title = 'Prompt' )

 w = Pmw.EntryField( dialog.interior(), label_text = prompt, labelpos = NW,
labelmargin = 1, entry_width = 50 )
 w.pack( padx = 15, pady = 15 )

 dialog.configure( activatecommand = w.focus_set )


The result of "dialog.configure( activatecommand = w.focus_set )" is that
the dialog doesn't get focus at all.

If I comment this line out, the dialog gets focus, but the user has to click
in the entry field, or tab twice to get to it (first tab goes to OK button).

Can anyone help?


More information about the Python-list mailing list