Re: Setting wm minsize on a toplevel widget

From: Erik Ostrom <eostrom_at_ccs.neu.edu>
Date: Thu, 13 Jul 1995 16:28:43 -0400

> 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"?

There's an X event called Map, which you can bind to the toplevel widget
to execute some code when it gets mapped. (There's also a MapRequest
event; I don't know the official definitions of these, but I think the
Map event does what you want.)

An example (using STklos):

(define (test value)
  (let* ((tl (make <Toplevel>))
         (t (make <Text> :value value :parent tl
                  :width (string-length value)
                  :height 1)))
    (pack t)
    (bind tl "<Map>" `(wm 'minsize ,(address-of tl)
                          (winfo 'width ,(address-of tl))
                          (winfo 'height ,(address-of tl))))))

Nothing too fancy: Create a toplevel and a widget that goes in it,
pack the widget, and bind the Map event to set minsize.

Things get a little tricky if any of the packed widgets use setgrid:
The winfo command will return height and width in pixels, but minsize
will treat the same numbers in units of character. Worse yet, the
new minsize won't take effect until somebody tries to resize it, at
which it will balloon up to some large multiple of its natural size.
I don't know the best way to get around this; anyone else?
Received on Thu Jul 13 1995 - 22:30:25 CEST

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