Skip to content
Advertisement

Cant exit fullscreen on tkinter window python

Im trying to make this window fullscreen, then be able to escape with any key. I can’t bind the escape key to actually escaping the window, can’t figure out where it’s going wrong from other similar posts too.

Here is the code:

JavaScript

Advertisement

Answer

On some systems (like Linux) root.overrideredirect(True) removes window manages (WM) which display border but WM also sends key/mouse events from system to your program. If WM doesn’t send event then your program doesn’t know that you clicked ESC.

This works for me on Linux Mint (based on Ubuntu and Debian). Rasbian is base on Debian.

JavaScript

I put root.after(5000, root.destroy) only for test – to close it after 5s if ESC will not work.

I use close_escape only to see if it was closed by ESC or after(). If code works then you can use root.bind("<Escape>", lambda event:root.destroy())

JavaScript

BTW: you may try also without root.overrideredirect() – maybe it will works for you

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement