Re: toplevel widget problems

From: Erik Ostrom <eostrom_at_ccs.neu.edu>
Date: Wed, 05 Jul 1995 13:12:05 -0400

> I've created a new composite widget class which I'd like to instantiate
> in its own window. I can create a new toplevel class fine, but how do I
> get my widget to pack inside it?
> (define t (make <Toplevel>))
> (pack my-widget :in t)
> doesn't do it.

You don't show the line where you created my-widget, but using the two
lines you showed consecutively couldn't possibly work. When you create
my-widget, you need to tell tk what window to put it in:

  (define t (make <Toplevel>))
  (define my-widget (make <My-Widget> :parent t)
  (pack my-widget) ^^^^^^^^^^

If you create my-widget without giving a :parent, then it lives in *root*,
and you can't move it into a whole other toplevel.

> Also, I'm having problems getting the Scrolltext class to be resizeable;
> it always wants to be 80x24 no matter what size I make the
> window. Anyone know the magic incantation?

Hm, I'm not sure I understand your question here, but I'll give an
answer to one interpretation:

If you want a widget to automatically resize with its parent, you need
to make that explicit when you pack it. So:

  (define t (make <Toplevel>))
  (define s (make <Scroll-Text> :parent t)
  (pack s)

just tells the packer to put s inside of t somehow; but if you replace
the last line with

  (pack s :expand #t :fill 'both)

then
  (1) the "parcel" for s--sort of an anonymous frame that goes around it--
      will expand to whatever the current size of t is--and
  (2) s itself will fill out the "parcel" in both directions

with the end result that s completely fills t, regardless of size.

Hope this helps
--Erik
Received on Wed Jul 05 1995 - 19:13:45 CEST

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