[Tkinter-discuss] Unbinding system keys (preventing F10 to activate the menu)

Martin aus Chemnitz MartinAusChemnitz at gmx.net
Wed Apr 11 09:02:41 CEST 2007


Hi!

Under Windows XP, pressing F10 in a Tkinter application actives the menu. I 
haven't found a way to unbind this events yet.

(I understand that system-wide events like Alt-Tab never reach the application, 
but that's not the case for F10.)

Here is an example application



from Tkinter import *

root = Tk()
menu = Menu(root)
menu.add_cascade(label="File")
root.config(menu=menu)

def callback(event):
     print "pressed ", event.keysym, " ", event.keysym_num

canvas = Canvas(root, width=100, height=100)
canvas.pack()

root.unbind("<KeyPress-F10>")
root.unbind("<Key-F10>")
root.bind("<KeyPress>", callback)

root.mainloop()



Pressing F7 F8 F9 F10 F9 F8 F7 will show you what I mean.

(The same behavior occurs when there is no menu at all. In this case, pressing 
F10 highlights the system menu (move, resize, ...), but does not open it up.)

Thanks for your help

Martin


More information about the Tkinter-discuss mailing list