tkInter constraining the width only

Roger rdcollum at gmail.com
Mon Dec 29 16:01:33 EST 2008


On Dec 29, 3:23 pm, akineko <akin... at gmail.com> wrote:
> Hello everyone,
>
> I'm writing a Tkinter program and trying to constraint the window
> size.
> I want to set the minimum of the width and the height and the maximum
> of the width, but not the height.

You want to set the max height to 0.  I know this is counter-
intuitive. Both values must be a number or None, not mixed.  So to do
what you want to do it would be this:

some_window.wm_minsize(width=min_width, height=min_height)
some_window.wm_maxsize(width=max_width, height=0)

Note that these numbers are in pixels if you're using .pack() and
according to the docs it's in grid coordinates if you're using .grid()

Good luck!
Roger.



More information about the Python-list mailing list