FAQ Index - Search - Recent Changes - Everything - Add entry

<< Previous Entry | FAQ Entry 5.20 | Next Entry >>

5.20. How do I move focus between widgets?

Two cases:

1) you want to move focus to particular widget:

widget.grab_focus()

2) move focus from a widget to the next widget, as if user pressed Tab key:

widget.get_toplevel().child_focus(gtk.DIR_TAB_FORWARD)

You can use other gtk.DIR_* constants, they correspond to moving focus wit h other keys; gtk.DIR_TAB_BACKWARD corresponds to Shift-Tab.

PyGTK FAQ Wizard | PyGTK Homepage | Feedback to faq at pygtk.org