Buğra Coşkun Buğra Coşkun - 1 year ago 112
Python Question

How to check if window is on Fullscreen in Tkinter?

I made F11 toggle fullscreen on. But how can I make it so that F11 can both toggle fullscreen on and off ?

I tried to make an [if] statement so it will turn it off if the window was previously toggled to fullscreen but I couldn't find a way to check if the window was already toggled or not.

Any help is appreciated, thank you.

Answer Source

This is the method I mentioned in my comment above:

from tkinter import *
root = Tk()


var = 0

def f(event):
    global var
    if var == 0:
        root.attributes("-fullscreen", True)
        var = 1
        root.attributes("-fullscreen", False)
        var = 0

root.bind("<F11>", f)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download