[Tkinter-discuss] calling function by keypress

mkiever at web.de mkiever at web.de
Tue May 16 13:08:17 CEST 2006


Hello Ilknur,

you need focus to get key events.
So normally you set focus for the parent of all buttons
(or the toplevel widget)
and also bind the command to that widget.
So:

  self.focus_set ()
  self.bind ( '<KeyPress>', self.assignkey )

in the __init__ of your class should work.
(your class needs to be a subclass of some widget, for example Frame)

Hope this helps,

Matthias Kievernagel
Software-Development
mkiever/at/web/dot/de



More information about the Tkinter-discuss mailing list