Re: Setting wm minsize on a toplevel widget

From: Hilmar Lapp <hili_at_al-bundy.biologie.uni-freiburg.de>
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 <eg_at_unice.fr>
STk> (toplevel '.mywin)
.mywin
STk> (wm 'withdraw '.mywin)
""
STk> (button '.mywin.mybutton :text "Sample Button"
                              :command '(destroy ".mywin"))
.mywin.mybutton
STk> (pack .mywin.mybutton :padx 5 :pady 5)
()
STk> (update)
()
STk> (update 'idletasks)
()
STk> (define x (winfo 'reqwidth '.mywin))
#[undefined]
STk> (define y (winfo 'reqheight '.mywin))
#[undefined]
STk> (display x)
104#[undefined]
STk> (display y)
32#[undefined]
STk> (wm 'minsize '.mywin x y)
""
STk> (wm 'deiconify '.mywin)
""
STk>

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

-----------------------------------------------------------------------------
Hilmar Lapp e-mail: hlapp_at_deep-thought.biologie.uni-freiburg.de
Institut f. Biologie II http://www.biologie.uni-freiburg.de/~hili/hili.html
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