Python 3.x - toggling fullscreen in tkinter Python 3.x - toggling fullscreen in tkinter tkinter tkinter

Python 3.x - toggling fullscreen in tkinter


not sure why it isn't working on your computer, but try this code sample:

#!python3import tkinter as tkgeom=""def fullscreen():    global geom    geom = root.geometry()    w = root.winfo_screenwidth()    h = root.winfo_screenheight()    root.overrideredirect(True)    root.geometry('%dx%d+0+0' % (w, h))def exitfullscreen():    global geom    root.overrideredirect(False)    root.geometry(geom)root = tk.Tk()tk.Button(root,text ="Fullscreen", command=fullscreen).pack()tk.Button(root,text ="Normal", command=exitfullscreen).pack()root.mainloop()

the one thing i'm making sure i do is to store the geometry before going fullscreen, and then re applying it when i exit fullscreen. the global statement was needed because if i didn't use it the fullscreen function stored the geometry in a local variable instead of the one i created at the top.


Change the overrideredirect flag before calling withdraw and deiconify.