Make Tkinter window full screen at start

 This guide will help to  Learn how to make a Python full screen tkinter  window Fill your entire screen using Tkinter. This code sets up a program that opens a fullscreen window, perfect for creating immersive applications and  to run them.

set tkinter window full screen

How to set Tkinter window full screen

 Making Full screen tkinter window

Here’s a simple Python script using Tkinter that creates a window which starts in full-screen mode. Tkinter is a standard GUI (Graphical User Interface) library for Python, and it allows you to create windows, buttons, and other GUI elements.

This example demonstrates how to create a basic full-screen window using python:

import tkinter as tk

This single line of code performs the following action that Imports the tkinter module as tk.

root = tk.Tk()

It is useful to create a root window.

root.attributes('-fullscreen', True)

This line  is to Set the root window to full-screen mode.

def exit_fullscreen(event):
    root.attributes('-fullscreen', False)

It defines a function to exit from the full screen when the escape key is pressed.

root.bind('<Escape>', exit_fullscreen)

This line  binds the escape key to call the exit full screen mode function.

root.mainloop()

It is the last line of the code it starts the main event loop to display window and handle events.

Below is the code demonstrates how to create a basic full-screen window in Tkinter :

import tkinter as tk

root = tk.Tk()
root.attributes('-fullscreen', True)

def exit_fullscreen(event):
    root.attributes('-fullscreen', False)

root.bind('<Escape>', exit_fullscreen)

root.mainloop()
output:

It is the full screen tkinter window .This will be the output if we run the above code. This code can be  executed in thonny. This is the required full screen window using python.

output when escape key is pressed:

The code enables the escape key to exit from the full-screen Tkinter window when pressed. It utilizes a function that is bound to the escape key event for this purpose. Furthermore, the attached image demonstrates the function’s operation, clearly showing how pressing the escape key smoothly returns the window from full-screen mode.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top