focus with PMW
Greg McFarlane
gregm at iname.com
Thu Apr 20 10:34:59 EDT 2000
On 18 Apr, Pete wrote:
> I am trying to determine which widget, the focus is currently on in my
> code. When I make a call to get_focus() it gives me an instance of a
> TKinter.Entry, but I am only creating PMW widgets (which are of course
> extended from TKinter). Since I am not creating TKinter widgets
> explicitly in my own code, how can I determine which PMW widget that
> specific TKinter.Entry instance belongs to?
You will need to maintain a list of all the Tkinter widgets in your
application that can get focus and compare them against the one
returned by focus.get(). You can get the component widgets of a
Pmw megawidget by using the component() method. For example
entryfield = Pmw.EntryField()
entry = entryfield.component('entry')
The Pmw documentation lists all the components of each megawidget,
along with their types.
However, would it not be better to use something like
bind('<FocusIn>') on all the widgets (or component widgets of
megawidgets) you are interested in, then your application can be
notified whenever focus changes, rather than having to ask for it.
--
Greg McFarlane INMS Telstra Australia gregm at iname.com
More information about the Python-list
mailing list