Accelerators not working in Python Tkinter : How to fix [duplicate] Accelerators not working in Python Tkinter : How to fix [duplicate] tkinter tkinter

Accelerators not working in Python Tkinter : How to fix [duplicate]


You have to use bind_all.

Accelerator is just a string that will shown on the right of the menu

Underline - to underline the selected index

tearoff - boolean to toggle the tear off feature

tearoff allows you to detach menus for the main window creating floating menus. If you create a menu you will see dotted lines at the top when you click a top menu item. If you click those dotted lines the menu tears off and becomes floating.

from tkinter import *def donothing(event=None):   filewin = Toplevel(root)   button = Button(filewin, text="Cool")   button.pack()root = Tk()menubar = Menu(root)helpmenu = Menu(menubar, tearoff=0)helpmenu.add_command(label="Help Index",accelerator="Ctrl+H", command=donothing)menubar.add_cascade(label="Help",underline=0 ,menu=helpmenu)root.config(menu=menubar)root.bind_all("<Control-h>", donothing)root.mainloop()