toplevel & embedded frame geometry 
Author Message
 toplevel & embedded frame geometry

Hi people

Can somebody help me figure out how this whole window geometry
business works? I've got a problem that I could swear looks like a bug.

I want to create a toplevel window with a fixed width of 300 pixels,
BUT I want the height to conform to the contents, which will be
packed into an embedded frame, vertically.

According to what I understand, that should be done as follows:

  toplevel .mytop -width 300
  # now make the rooot window invisible
  withdraw .

That alone works as expected. I get a window that's 300 wide and has
zero
height since there's nothing in it yet.

Now I want to add things into an embedded frame.
So I add a frame:

  frame .mytop.myframe
  pack .mytop.myframe -side top

Oops! Right away there's a problem. The whole window shrinks down
to zero size! How come??

As it turns out, as I add things to .mytop.myframe, it expands to
show the components. But I need the width to stay constant!
What's going on?

Thanks a lot, Adrian



Mon, 04 Oct 2004 22:13:29 GMT  
 toplevel & embedded frame geometry
By default, children control the size of their parents. You can turn this
off using "pack propagate . 0" (or grid propagate..., if you were using the
grid geometry manager...). When you do this, the size you set for your
toplevel will "stick", and the children won't cause the window to resize.

What you want, however, is not that. You want a fixed width but dynamic
height. You can get this by leaving propagation on, then resetting the width
of the window *after* adding all of the other windows. As you are adding
windows the size will grown or shrink accordingly. Before mapping the
window, change its size to whatever you want.

--
Bryan Oakley



Mon, 04 Oct 2004 23:28:40 GMT  
 toplevel & embedded frame geometry

Quote:
> What you want, however, is not that. You want a fixed width but dynamic
> height. You can get this by leaving propagation on, then resetting the width
> of the window *after* adding all of the other windows. As you are adding

Maybe I'm misunderstanding you, but is this what you mean?

 toplevel .mytop
 frame .mytop.myframe
 # < now put some things into the frame... >

 pack .mytop.myframe -side top
 .mytop configure -width 300

I ask because this doesn't work. For some reason I can't understand,
the last configure-command does nothing. The toplevel stays just
the size it needs to fit the frame.
In fact, when I query the width using:

 puts [.mytop cget -height]

it tells me the height is 0! My idea was to get the height it needed
to pack all components, and then call wm geometry 300 <height>,
but if it thinks the height is zero I'm stuck.

Am I doing something wrong or missing something?

Thanks again, Adrian



Tue, 05 Oct 2004 22:25:49 GMT  
 toplevel & embedded frame geometry

Quote:

> In fact, when I query the width using:
>  puts [.mytop cget -height]
> it tells me the height is 0! My idea was to get the height it needed
> to pack all components, and then call wm geometry 300 <height>,
> but if it thinks the height is zero I'm stuck.

Look at [winfo reqheight] and [winfo height].  And remember that geometry
managers do most of their work in idle events.

Donal.
--

-- What's the reason of long discussions, if at the end someone says, "we have



Fri, 08 Oct 2004 18:00:28 GMT  
 toplevel & embedded frame geometry

Quote:
> Look at [winfo reqheight] and [winfo height].  And remember that geometry
> managers do most of their work in idle events.

This doesn't help me either (sorry!)

The requested dimensions are 200x200, and once I've
packed the components [winfo height/width] both return 0.

This 200x200 somehow comes from the size of the default
toplevel. For example, when I execute the following program,
a 200x200 empty toplevel pops up:

  #!/usr/local/bin/wish
  set a "hello"
  puts $a

Does this give you any hints? It's as if no commands that exist
are able to return the true allocated window size. It's either
given as zero or some initial requested default size (200x200),
regardless of what's been packed into the window.
And this is of course AFTER all the pack commands have
been executed.

Thanks again, Adrian

--
Adrian Schubert            | Remote Sensing Laboratories
TEL: +41 +1 635-6523       | University of Zurich

www.geo.unizh.ch/~schubert | CH-8057 Zurich, Switzerland



Fri, 08 Oct 2004 21:17:33 GMT  
 toplevel & embedded frame geometry
Donal gave you a hint, but it was rather subtle (idle events).

After you create and pack your widgets, issue an 'update'. winfo should
then report valid numbers.

Quote:

> --------------CBC0FC43AB5D491DC8187E47
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit

>> Look at [winfo reqheight] and [winfo height].  And remember that geometry
>> managers do most of their work in idle events.

> This doesn't help me either (sorry!)

> The requested dimensions are 200x200, and once I've
> packed the components [winfo height/width] both return 0.

> This 200x200 somehow comes from the size of the default
> toplevel. For example, when I execute the following program,
> a 200x200 empty toplevel pops up:

>   #!/usr/local/bin/wish
>   set a "hello"
>   puts $a

> Does this give you any hints? It's as if no commands that exist
> are able to return the true allocated window size. It's either
> given as zero or some initial requested default size (200x200),
> regardless of what's been packed into the window.
> And this is of course AFTER all the pack commands have
> been executed.

> Thanks again, Adrian

> --
> Adrian Schubert            | Remote Sensing Laboratories
> TEL: +41 +1 635-6523       | University of Zurich

> www.geo.unizh.ch/~schubert | CH-8057 Zurich, Switzerland

> --------------CBC0FC43AB5D491DC8187E47
> Content-Type: text/html; charset=us-ascii
> Content-Transfer-Encoding: 7bit

><!doctype html public "-//w3c//dtd html 4.0 transitional//en">
><html>

><blockquote TYPE=CITE>Look at [winfo reqheight] and [winfo height].&nbsp;
> And remember that geometry
><br>managers do most of their work in idle events.</blockquote>
> This doesn't help me either (sorry!)
><p>The requested dimensions are 200x200, and once I've
><br>packed the components [winfo height/width] both return 0.
><p>This 200x200 somehow comes from the size of the default
><br>toplevel. For example, when I execute the following program,
><br>a 200x200 empty toplevel pops up:
><p><tt>&nbsp; #!/usr/local/bin/wish</tt>
><br><tt>&nbsp; set a "hello"</tt>
><br><tt>&nbsp; puts $a</tt>
><p>Does this give you any hints? It's as if no commands that exist
><br>are able to return the true allocated window size. It's either
><br>given as zero or some initial requested default size (200x200),
><br>regardless of what's been packed into the window.
><br>And this is of course AFTER all the pack commands have
><br>been executed.
><p>Thanks again, Adrian
><pre>--&nbsp;
> Adrian Schubert&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Remote Sensing Laboratories&nbsp;
> TEL: +41 +1 635-6523&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | University of Zurich

> www.geo.unizh.ch/~schubert | CH-8057 Zurich, Switzerland</pre>
> &nbsp;</html>

> --------------CBC0FC43AB5D491DC8187E47--

--
Marty Backe
-------------------------------
http://www.lucidway.org/tclwiki


Sat, 09 Oct 2004 00:43:28 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. How do I pack things in a frame in a toplevel frame

2. Problem with toplevel geometry

3. wm geometry $toplevel +x+y does not work on iconified window

4. adapting geometry when resizing toplevel window..

5. Getting the real geometry of a toplevel...

6. x windows geometry screwed up after a frame drag

7. frame geometry

8. frame files in a toplevel file

9. Frame in Toplevel

10. container frame w/toplevel problems (win98)

11. Creating toplevel window frame with titlebar only

12. toplevel with window frame only

 

 
Powered by phpBB® Forum Software