[Tutor] starting a tkinter window maximized

Harry Kattz gibbs05@flash.net
Thu, 3 May 2001 12:53:46 -0500


> The subject pretty much says it all! How does one tell a tkinter window to
> start maximized in windows or X?

I didn't see an answer to this one yet, so I'll give it a shot.

wm_state('zoomed') should maximize on Windows.  For example:

    >>> import os
    >>> from Tkinter import *
    >>> class MaxWin(Tk):
    ...        def __init__(self):
    ...            Tk.__init__(self)
    ...            Label(self, text = "Test Zoom").pack()
    ...            if os.name == 'nt':
    ...                self.wm_state('zoomed')
    ...
    >>> test = MaxWin()
    >>> test.mainloop()

This produced a full size window with a label.

Zoomed isn't valid for Unix so, as far a I know, you'd have to calculate
screen width & height and set your window size accordingly.  I don't suggest
you do this though, because I've had some Unix users tell me maximizing an
app is very rude.

Good luck,
Sam