I'm making a menubar in Tkinter with an accelerator:
menubar = tk.Menu(window)
file_menu = tk.Menu(menubar)
menubar.add_cascade(label='File', menu=file_menu)
window.config(menu=menubar)
file_menu.add_command(label='Open resource pack', command=openPack, accelerator='Cmd o' if IS_MAC else 'Ctrl o')
window.bind_all('<M1-o>' if IS_MAC else '<Control-o>', openPack)
file_menu.add_command(label='Copy original pack', command=copyOriginalPack, accelerator='Shift Cmd c' if IS_MAC else 'Shift Ctrl c')
window.bind_all('<M1-C>' if IS_MAC else '<Control-C>', copyOriginalPack)
But for the Copy original pack
option the key combination is Shift Command C. The accelerator only shows the key combination in the menubar but doesn't actually run the command, so I have to manually bind to the window.
If I remember correctly, to bind Shift Command C I just need to say Control C
and make the C uppercase because of Shift.
But I can't bind Shift. It works if I click the menu option, but the key combo doesn't. It works for the other option, which doesn't have Shift
CodePudding user response:
I fixed it by writing <M1-Shift-c>
(note the lowercase c)