Re: Pack , bind, & scrollbar help
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: Pack , bind, & scrollbar help

From: Bryan Oakley <oakley@bardo.clearlight.com>
Date: Mon Feb 27 2006 - 01:43:03 CET

Ray wrote:
> 1) I can't figure out how to get things positioned. I want the items
> positioned like:
> Selection frame
> Result frame
> Buttons
> but instead I get
> Selection frame Result Frame
> Buttons
>

The selection frame and result frame appear side by side because you put
them all in the same frame ($w.frame). Put them in separate frames. You
want the topmost packing to look like this:

     pack $selectionFrame -side top -fill x
     pack $resultFrame -side top -fill both -expand 1
     pack $buttonFrame -side bottom -fill x

Then, you pack the selection listbox and scrollbar in the selection
frame, the result listbox and scrollbars in the resultFrame, and the
buttons in the button frame.

BTW: if you are putting both a horizontal and vertical scrollbars in the
same frame you should use grid rather than pack. With pack you'll likely
end up with one of the scrollbars overlapping the other. Overlap isn't
quite the right word, but what you normally want is a small square below
the vertical scrollbar and to the right of the horizontal scrollbar. You
can't do this easily with pack.

The key to using pack is to not be afraid to use all the frames you need
to get the job done. Frames are lightweight -- even a worse case of a
few dozen extra frames won't incur noticible overhead. Every logical
group of widgets (eg: a widget and its scrollbar(s), a set of buttons,
etc) should go in a separate frame.

If you don't like creating all those frames you can eliminate virtually
all of them and just organize everything with grid. That sometimes
requires a bit of creativity, but often its quite straight forward. Get
out a piece of graph paper and lay it all out and it becomes pretty easy
to translate that into grid commands.
Received on Sun Apr 30 02:16:24 2006