tags:

views:

60

answers:

0

The Python Pmw Group widget has an issue with tab ordering.

Running the following code will illustrate the issue:

import Pmw
import Tkinter

#Create a window to house the Group widgets
window = Tkinter.Tk()

#Run the Pmw activation function for the new Tkinter window
Pmw.initialise(window)

#Loop to create the widgets
#Just for fun, lets make five
for _ in range(5):

    #The "tag" is the "header" widget for the Group that will, by default, "takefocus"
    #We could as well use any widget which takes focus, like a button or entry widget
    #The "master" of the group will be the window we created earlier
    group = Pmw.Group(window, tag_pyclass=Tkinter.Checkbutton)

    #We need another widget, this time inside the group, to "takefocus" as well
    #This widget will use the Group's interior as it's "master" instead of the window
    entry = Pmw.EntryField(group.interior())

    #Map the widgets onto the screen so that they are interactive and visible
    group.pack()
    entry.pack()

#Display the window and run the interaction layer's loop
window.mainloop()

Bringing focus to the first entry field then tabbing will visually move you upwards, towards the check button above. Then tabbing again will move you past the entry field, the next check button and into the next entry field.

I could orchestrate a huge amount of code to override all of the tab ordering in Tkinter, but that seems like overkill and could potentially pollute the rest of the program.

Can anyone suggest a wrapper or similar to restore tab order to this widget?

Theory: The Group's interior focusable object (in this instance an entry widget) would appear to be created before the "tag" widget.

Theory: There is some weird focus logic happening within Pmw's Group widget.