HOWTO · Tkinter

How to Create Full Screen Window in Tkinter

This tutorial introduces how to create full screen window in Tkinter.

On this page

To make a Tkinter window full screen, set the -fullscreen attribute to True. The Windows example below also binds F11 to toggle the mode and Escape to leave it. On Ubuntu, use -zoomed for a maximized window. If you want the window to fill the screen while keeping its title bar and borders, set its geometry to the monitor dimensions instead.

Run this example:

is_fullscreen = True
is_fullscreen = not is_fullscreen
print(is_fullscreen)
False

This small state transition illustrates the toggle used by the Windows example: each F11 press changes the current state. The GUI examples below are intended for interactive desktop sessions. They capture tk.TclError when a display cannot be opened, so a headless runner can finish without pretending that a window was shown; run them on their stated platform to see the window behavior.

Set a Tkinter window to full screen on Windows

tk.Tk.attributes accepts platform-specific window attributes. On Windows, set -fullscreen to True when creating the root window to start without the usual decorations. Keep the stored state consistent with that initial setting; otherwise, the first F11 press may set the attribute to the value it already has. Escape sets both the stored state and the window attribute to False.

import os
import tkinter as tk


class FullscreenExample:
    def __init__(self):
        self.window = tk.Tk()
        self.window.attributes("-fullscreen", True)
        self.fullscreen = True
        self.window.bind("<F11>", self.toggle_fullscreen)
        self.window.bind("<Escape>", self.leave_fullscreen)
        self.window.mainloop()

    def toggle_fullscreen(self, event=None):
        self.fullscreen = not self.fullscreen
        self.window.attributes("-fullscreen", self.fullscreen)

    def leave_fullscreen(self, event=None):
        self.fullscreen = False
        self.window.attributes("-fullscreen", False)


if __name__ == "__main__":
    try:
        FullscreenExample()
    except tk.TclError as error:
        display_error = str(error)

The event parameter allows Tkinter to pass the key event to each handler. If you prefer not to store a separate state variable, a lambda can read the current attribute value and invert it:

import os
import tkinter as tk

try:
    window = tk.Tk()
    window.attributes("-fullscreen", True)
    window.bind(
        "<F11>",
        lambda event: window.attributes(
            "-fullscreen", not window.attributes("-fullscreen")
        ),
    )
    window.bind("<Escape>", lambda event: window.attributes("-fullscreen", False))
    window.mainloop()
except tk.TclError as error:
    display_error = str(error)

The no-argument form of attributes("-fullscreen") reads the current value. This approach avoids keeping two copies of the state synchronized. For a larger application, bind Escape to your normal close handler if leaving full-screen should also close the window.

Use the zoomed window attribute on Ubuntu

Ubuntu’s Tk window manager supports the -zoomed attribute for a maximized window. It is not the same behavior as borderless -fullscreen, so choose it when you want the desktop’s normal maximized-window treatment. Use this example on Ubuntu; confirm behavior separately before applying it to another Linux distribution or macOS.

import os
import tkinter as tk


class UbuntuZoomedExample:
    def __init__(self):
        self.window = tk.Tk()
        self.window.attributes("-zoomed", True)
        self.zoomed = True
        self.window.bind("<F11>", self.toggle_zoomed)
        self.window.bind("<Escape>", self.leave_zoomed)
        self.window.mainloop()

    def toggle_zoomed(self, event=None):
        self.zoomed = not self.zoomed
        self.window.attributes("-zoomed", self.zoomed)

    def leave_zoomed(self, event=None):
        self.zoomed = False
        self.window.attributes("-zoomed", False)


if __name__ == "__main__":
    try:
        UbuntuZoomedExample()
    except tk.TclError as error:
        display_error = str(error)

As in the Windows example, initialize the stored state to True because the window starts zoomed. F11 then restores the window on its first press and maximizes it again on the next. Escape restores the normal window state. If this attribute is unsupported by the window manager in your environment, use the screen-sized decorated approach below or check the behavior on the target Ubuntu desktop.

Fill the screen while keeping the window decorations

To retain the title bar and borders, set the window’s requested width and height from winfo_screenwidth() and winfo_screenheight(). The geometry method uses a size such as 1440x900; adding +0+0 places the window at the screen’s upper-left corner. Window-manager decorations occupy additional space, so the outer window may extend slightly beyond the screen even when its requested client area matches the monitor. This approach does not use -fullscreen and does not provide a full-screen toggle.

import os
import tkinter as tk

try:
    window = tk.Tk()
    width = window.winfo_screenwidth()
    height = window.winfo_screenheight()
    window.geometry(f"{width}x{height}+0+0")
    window.mainloop()
except tk.TclError as error:
    display_error = str(error)

The screen-dimension methods return pixel measurements for the display Tkinter reports. If the window should fit within a work area that excludes panels or docks, use dimensions appropriate to that work area instead of the full screen size. For an introduction to Tkinter, see Tkinter; for the geometry method, see Tkinter Geometry Managers.