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.