Re: Setting wm minsize on a toplevel widget

From: Hilmar Lapp <>
Date: Thu, 13 Jul 1995 11:15:14 +0200

On Wed, 12 Jul 1995, Jin S. Choi wrote:

> I'd like to pack some things into a toplevel widget, then set the
> minsize of that toplevel to its natural size after it gets mapped. But I
> can't just pack, get the geometry and set the minsize all at once,
> presumably because the window won't have mapped by the time the geometry
> gets queried. Is there any way to say "wait until this window gets
> mapped"?

Withdraw the toplevel window, pack your widgets into it, update everything
and then query the window how large it wants to be. After setting the
minsize according to the query results you may map it by deiconifying it:

al-bundy: tcltk 10:01 9>stk
Welcome to the STk interpreter version 2.1.6 [Linux-1.1-i486]
Copyright (C) 1993, 1994 Erick Gallesio - I3S - CNRS / UNSA <>
STk> (toplevel '.mywin)
STk> (wm 'withdraw '.mywin)
STk> (button '.mywin.mybutton :text "Sample Button"
                              :command '(destroy ".mywin"))
STk> (pack .mywin.mybutton :padx 5 :pady 5)
STk> (update)
STk> (update 'idletasks)
STk> (define x (winfo 'reqwidth '.mywin))
STk> (define y (winfo 'reqheight '.mywin))
STk> (display x)
STk> (display y)
STk> (wm 'minsize '.mywin x y)
STk> (wm 'deiconify '.mywin)

BTW you won't need "withdraw" and "deiconify" if you just want to set the
minsize in order to make the toplevel resizable. Just pack the widgets,
query the window and set the minsize as shown above, and the toplevel will
be resizable. You'll need withdraw/deiconify if you want to preset or
_modify_ the geometry of a toplevel, e.g. set the location of the window
to a calculated position.

Hope this helps.


Hilmar Lapp e-mail:
Institut f. Biologie II
Universitaet Freiburg phone : +49 761 203 2656
Received on Thu Jul 13 1995 - 11:24:30 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST