How to display full-screen mode on Tkinter?

TkinterPythonServer Side ProgrammingProgramming

Tkinter displays the application window by its default size. However, we can display a full-screen window by using attributes('fullscreen', True) method. The method is generally used for assigning a tkinter window with properties like transparentcolor, alpha, disabled, fullscreen, toolwindow, and topmost.

Example

#Import the tkinter library
from tkinter import *

#Create an instance of tkinter frame
win = Tk()

#Set the geometry
win.geometry("650x250")

#Add a text label and add the font property to it
label= Label(win, text= "Hello World!", font=('Times New Roman bold',20))
label.pack(padx=10, pady=10)

#Create a fullscreen window
win.attributes('-fullscreen', True)

win.mainloop()

Output

Running the above code will display a full-screen window that can be closed by pressing the Alt+ F4 key.

raja
Published on 26-Mar-2021 10:50:51
Advertisements