Category Archives: Python

Python tkinter minimize or maximize the windows

Example of minimize or maximize the TK window in Python

Following code show the example of minimize or open the tk window as below:

tkWindow.state(newstate=’iconic’) is used for the minimize the window.

tkWindow.state(newstate=’normal’) is used for the maximize the window.

from tkinter import *
import time

#tkwindow in the 
tkWindow = Tk()  
tkWindow.geometry('500x500')  
tkWindow.title('Test the utility')



#set window background color
tkWindow.configure(bg='lightgray')

#Set the state newstate
def minimize1(): 
    #make the window minimize 
    tkWindow.state(newstate='iconic')
    time.sleep(3)
    # for make the window maximize or open
    tkWindow.state(newstate='normal')

Button1 = Button(tkWindow, text="Minimize", command=minimize1)
Button1.grid(row=2, column=6, padx=10, pady=20)  

tkWindow.mainloop()