Initialize a window as maximized in Tkinter Python


Tkinter creates a default window with its default size while initializing the application. We can customize the geometry of the window using the geometry method.

However, in order to maximize the window, we can use the state() method which can be used for scaling the tkinter window. It maximizes the window after passing the “zoomed” state value to it.

Example

#Import the required libraries
from tkinter import *

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

#Set the geometry of frame
win.geometry("600x400")

#Create a text label
Label(win,text="It takes only 21 days to create a new Habit", font=('Times
New Roman bold',15)).pack(pady=20)

#Maximize the window using state property
win.state('zoomed')

win.mainloop()

Output

Running the above code will maximize the tkinter window.

Updated on: 08-Oct-2021

6K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements