tkinter python maximize window tkinter python maximize window tkinter tkinter

tkinter python maximize window


You can do it by calling

root.state('zoomed')


If you want to set the fullscreen attribute to True, it is as easy as:

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

However, it doesn't show the title bar. If you want to keep it visible, you can resize the Tk element with the geometry() method:

root = Tk()w, h = root.winfo_screenwidth(), root.winfo_screenheight()root.geometry("%dx%d+0+0" % (w, h))

With winfo_width() and winfo_height() you can get the width and height or the window, and also you can bind an event handler to the <Configure> event:

def resize(event):    print("New size is: {}x{}".format(event.width, event.height))root.bind("<Configure>", resize)


To show maximized window with title bar use the 'zoomed' attribute

root = Tk()root.attributes('-zoomed', True)