'Tkinter bind Mac OS "command+q"
I'm trying to "stop" the root window exiting when I press "Command+q" but it's impossible.
The other key shortcuts work on my Mac OS, even in Windows/Linux, "Alt+F4" bind is possible to "capture", but in Mac OS is impossible for me.
Any ideas?
Thank you very much.
Solution 1:[1]
Finally I discovered the solution. The solution is as it must be always. You have to activate a "Mac Menu" to activate system functions like Command-Q behaviour:
mac_app_menu = Menu(menubar , name = "apple")
menubar.add_cascade(menu = mac_app_menu)
root.createcommand("tk::mac::ShowPreferences" , lambda: "whatever")
root.createcommand("tk::mac::Quit" , lambda: "before quit things")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | nastiliano |