tkinter python maximize window

tkinter python maximize window

Asked on November 24, 2018 in tkinter.
Add Comment


  • 4 Answer(s)

    You can use this solution:

        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)
    
    Answered on November 24, 2018.
    Add Comment

    This  could be a alternative solution,

        It  is done by calling

    root.state('zoomed')
    

     

    Answered on November 24, 2018.
    Add Comment

    Here is the answer

        The  maximized window with title bar use the ‘zoomed’ attribute

    root = Tk()
    root.attributes('-zoomed', True)
    
    Answered on November 24, 2018.
    Add Comment

    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)
    Answered on February 25, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.