Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
How to create a borderless fullscreen application using Python-3 Tkinter?
In order to make a Tkinter window borderless and full-screen, we can use the utility method attributes('-fullscreen', True). Tkinter windows can be configured using functions and methods defined in the Tkinter library.
Another similar method Tkinter provides to make the application window full-screen is overrideredirect(True). This method can be invoked only if the application needs to resize in its defined width and height only.
Method 1: Using attributes('-fullscreen', True)
The attributes('-fullscreen', True) method creates a true fullscreen window that covers the entire screen including the taskbar ?
# Import the required Libraries
from tkinter import *
# Create an instance of Tkinter frame
win = Tk()
# Set the Geometry
win.geometry("750x250")
# Full Screen Window
win.attributes('-fullscreen', True)
def quit_win():
win.destroy()
# Create a Quit Button
button = Button(win, text="Quit", font=('Comic Sans', 13, 'bold'), command=quit_win)
button.pack(pady=20)
win.mainloop()
Running the above code will display a full-screen window that covers the entire screen. Click the "Quit" button to close the full-screen window.
Method 2: Using overrideredirect(True)
The overrideredirect(True) method removes the window decorations (title bar, borders) but doesn't automatically make it fullscreen ?
from tkinter import *
# Create an instance of Tkinter frame
win = Tk()
# Remove window decorations
win.overrideredirect(True)
# Get screen dimensions and set window to fullscreen
screen_width = win.winfo_screenwidth()
screen_height = win.winfo_screenheight()
win.geometry(f"{screen_width}x{screen_height}+0+0")
def quit_win():
win.destroy()
# Create a Quit Button
button = Button(win, text="Quit", font=('Arial', 12, 'bold'), command=quit_win)
button.pack(pady=20)
# Add Escape key binding to quit
win.bind("<Escape>", lambda e: quit_win())
win.mainloop()
This method gives you more control over the window appearance and allows you to add custom exit methods like the Escape key.
Comparison
| Method | Window Decorations | Covers Taskbar | Best For |
|---|---|---|---|
attributes('-fullscreen', True) |
Hidden | Yes | Simple fullscreen apps |
overrideredirect(True) |
Removed | Depends on geometry | Custom borderless windows |
Adding Exit Options
Since fullscreen windows hide the close button, always provide exit methods ?
from tkinter import *
win = Tk()
win.attributes('-fullscreen', True)
def quit_win():
win.destroy()
# Multiple exit options
button = Button(win, text="Quit", font=('Arial', 12, 'bold'), command=quit_win)
button.pack(pady=20)
# Escape key to quit
win.bind("<Escape>", lambda e: quit_win())
# F11 to toggle fullscreen
def toggle_fullscreen(event=None):
win.attributes('-fullscreen', not win.attributes('-fullscreen'))
win.bind("<F11>", toggle_fullscreen)
win.mainloop()
Conclusion
Use attributes('-fullscreen', True) for simple fullscreen applications. Use overrideredirect(True) when you need more control over window behavior and custom borderless designs.
