Cristian,
You have to bind your Alt key presses separately. The underline= only
underlines the letter - it does not bind to an event handler.
Here's a snippet that may give you some ideas. Disclaimer: I'm not sure
if its best practice or not.
Malcolm
"""
Treat Alt+I as a shortcut keystroke for the Insert button
"""
import Tkinter as tk
import ttk
def onClick( event=None ):
if event:
print event.keysym, event.keysym_num, event.state
# event.state == 131104 regardless of left or right alt
key
if event.keysym == 'i' and event.state == 131104:
pass
else:
return
button1.focus_set()
entry1.delete( 0, 'end' )
entry1.insert( 'end', '<Open clicked>' )
root = tk.Tk()
style = dict( padx=24, pady=24 )
entry1 = tk.Entry( root )
entry1.pack( **style )
entry2 = tk.Entry( root )
entry2.pack( **style )
button1 = ttk.Button( root, text='Insert text', underline=0,
command=onClick )
button1.pack( **style )
# bind shortcut keystrokes at the outermost container
root.bind( '<Key>', onClick )
root.mainloop()
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss