Binding menu accelerator to a callback

Rich Shepard rshepard at appl-ecosys.com
Tue Jan 12 13:59:34 EST 2021


Menu options work from the menu, but not from the accelerator associated
with that menu item. My research suggests that while 'command' works for the
menu item, 'bind' is required for the associated accelerator. For example,
File -> Quit is defined this way:

 	self.file_menu.add_command(
             label="Quit",
             command=self.fileQuit,
             underline=0,
             accelerator='Ctrl+Q'
         )
and works when I pull down the File menu and click on 'Quit.'

I want to modify the menu items so the accelerator is bound to the same
self.fileQuit() (in this case). My web research hasn't found a solution
since examples for using bind() aren't in menus.

Do I need another method that associates accelerators with the callbacks?

Rich


More information about the Python-list mailing list