This Python script creates a fullscreen, black window using the built-in tkinter library.
It is designed to cover the entire screen and stay on top of all other windows.
The close button (❌) is disabled to prevent the user from closing the window manually.
- Launches a borderless fullscreen black window.
- Stays always on top of all other applications.
- Disables the window close button to prevent accidental exit.
- Uses only the standard Python library (no external dependencies).
import tkinter
root = tkinter.Tk()
root.attributes('-fullscreen', True) # Enable fullscreen
root.attributes('-topmost', True) # Keep window on top
root.config(bg='black') # Set background color to black
root.protocol("WM_DELETE_WINDOW", lambda: None) # Disable close button
root.mainloop() # Run the Tkinter event loop-
Make sure you have Python 3.x installed.
-
Save the code to a file, for example:
fullscreen_black.py -
Run the file from the terminal or command prompt:
python fullscreen_black.py
-
To exit, you’ll need to use a system shortcut (like
Alt + F4on Windows orCommand + Qon macOS).
On macOS, Tkinter’s handling of fullscreen and window layering is different from Windows and Linux. The following issues may occur:
- The
-fullscreenattribute may not truly hide the menu bar or dock. - The
-topmostattribute is not always respected by macOS’s window manager (the window might go behind other apps). - The
WM_DELETE_WINDOWoverride can still be bypassed via the macOS “Force Quit” dialog.
To make this work more reliably on macOS:
-
Replace:
root.attributes('-fullscreen', True)
with:
root.attributes('-zoomed', True)
(This makes the window fill the screen more consistently.)
-
Add the following lines before
root.mainloop():root.lift() root.focus_force()
-
Make sure you’re using Python installed via python.org, not the macOS system Python, as Tkinter behaves inconsistently with the system version.