Search code examples
pythonwindowstkinterkeyboard-shortcutskeyboard-events

Python Tkinter deiconify withdrawn window with a keyboard shortcut


Is there a way to withdraw a window and deiconify it using a keyboard shortcut? If I do something like: root.bind("<Control-q>", lambda event: root.deiconify()), it doesn't trigger when the window is withdrawn. If there isn't a way to do it with Tkinter, is there a module that works on Windows that will allow me to do that?


Solution

  • Yes there is a way by using the keyboards module. The keyboards module globally binds keyboard events so it won't matter if your iconified window is no longer on focus.

    See this link: Is there a way to deiconify root window with keyboard binding?