underline a letter in a button to use "ALT+key" shortcut with Tkinter

QWE leomasi at libero.it
Wed Apr 2 15:32:32 EST 2003


On Wed, 2 Apr 2003 11:53:35 +0200, "Federico"
<maschio_77 at hotmail.com> wrote:

>With Tkinter how can I underline a letter in the text in a button and set an
>"ALT+Key" shortcut for that button? is there some library I can use?
>Thanks
>
from Tkinter import *

def click():
    label.configure(text="Hello World")

root=Tk()
button=Button(root,text="Click Me",command=click, underline=6)
button.pack()
label=Label(root)
label.pack()
root.bind('<Alt_L><m>', lambda e:click())
root.mainloop()





More information about the Python-list mailing list