Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tk pack as in html

18 views
Skip to first unread message

Gernot Frisch

unread,
Oct 29, 2008, 9:23:58 AM10/29/08
to
I want to pack my widgets like this:
[A][ B ][C]


And then I want a "command" that says: start a new line, thus create this:

[A][ B ][C]
[ D ][ E ]
[ F ]

(How) can I do this?

--
------------------------------------
Gernot Frisch
http://www.glbasic.com

oak...@bardo.clearlight.com

unread,
Oct 29, 2008, 9:31:34 AM10/29/08
to
On Oct 29, 8:23 am, "Gernot Frisch" <m...@privacy.net> wrote:
> I want to pack my widgets like this:
> [A][  B  ][C]
>
> And then I want a "command" that says: start a new line, thus create this:
>
> [A][  B  ][C]
> [  D  ][ E  ]
> [    F      ]
>
> (How) can I do this?

Are you saying you want this command to actually add two lines as in
your diagram, where one line has two widgets and the next has one?
It's not clear what you're wanting to do.

Are you having problems understanding how to add a line, or how to get
the widgets to expand properly, or both?

Gernot Frisch

unread,
Oct 29, 2008, 9:58:38 AM10/29/08
to

> I want to pack my widgets like this:
> [A][ B ][C]
>
> And then I want a "command" that says: start a new line, thus create this:
>
> [A][ B ][C]
> [ D ][ E ]
> [ F ]
>
> (How) can I do this?

> Are you saying you want this command to actually add two lines as in
> your diagram, where one line has two widgets and the next has one?
> It's not clear what you're wanting to do.
>
> Are you having problems understanding how to add a line, or how to get
> the widgets to expand properly, or both?

My problem is, that "pack" can either pack them A-B-C, or
A
B
C

But not
A-B-C
D-E-F

So, I'm asking how to pack3 widgets side by side, and then a different count
of widgets side by side _below_ the first ones.

suchenwi

unread,
Oct 29, 2008, 10:10:18 AM10/29/08
to
On 29 Okt., 14:23, "Gernot Frisch" <m...@privacy.net> wrote:
> I want to pack my widgets like this:
> [A][  B  ][C]
>
> And then I want a "command" that says: start a new line, thus create this:
>
> [A][  B  ][C]
> [  D  ][ E  ]
> [    F      ]
>
> (How) can I do this?

Either with nested frames:
pack [frame .1]
pack .1.a .1.b .1.c -side left
pack [frame .2]
pack .2.d .2.e
pack .f

or with [grid]:
grid .a .b - .c
grid .d - .e -
grid .f - - -

Uwe Klein

unread,
Oct 29, 2008, 10:18:39 AM10/29/08
to
well the traditional way used to be subframes
i.e. you pack A B C in a subframe .abc with widgets .abc.a .abc.b .abc.c
in -side left order.
same for D and E
then you pack
.abc
.de
.f
in the -side top

The alternative is to use the grid packer ( or blt_table )
you can give row and column positions and adjust rowspan/colspan.
see man n grid

uwe

oak...@bardo.clearlight.com

unread,
Oct 29, 2008, 10:37:07 AM10/29/08
to
On Oct 29, 8:58 am, "Gernot Frisch" <m...@privacy.net> wrote:
> My problem is, that "pack" can either pack them A-B-C, or
> A
> B
> C
>
> But not
> A-B-C
> D-E-F
>
> So, I'm asking how to pack3 widgets side by side, and then a different count
> of widgets side by side _below_ the first ones.

As others have said, the common solution is to use nested frames. You
can create almost any sort of layout with that scheme.

Don't let multiple frames scare you. Look at them as a tool rather
than an obstacle. You don't have to make your significant widgets a
child of a deeply nested hierarchy. Make use of the -in option to make
it easy to change your layout without having to rename your widgets.

For example, *instead* of this:

frame .container
frame .container.row1
frame .container.row1.column1
...
button .container.row1.column1.button1
pack .container.row1.column1.button1

Do this:

frame .container
frame .container.row1
frame .container.row1.column1
...
button .button1
pack .button1 -in .container.row1.column1

This makes it easy to, in effect, separate your presentation (the
layers of frames) from your content (loosely speaking, non-frame
widgets). If you later decide you need more nested frames to get
things right you only have to add the frames and adjust the packing,
you don't have to go and rename all your buttons, entry widgets and so
on throughout your code.


Glenn Jackman

unread,
Oct 29, 2008, 11:17:14 AM10/29/08
to
At 2008-10-29 10:37AM, "oak...@bardo.clearlight.com" wrote:
> For example, *instead* of this:
>
> frame .container
> frame .container.row1
> frame .container.row1.column1
> ...
> button .container.row1.column1.button1
> pack .container.row1.column1.button1
>
> Do this:
>
> frame .container
> frame .container.row1
> frame .container.row1.column1
> ...
> button .button1
> pack .button1 -in .container.row1.column1
>
> This makes it easy to, in effect, separate your presentation (the
> layers of frames) from your content (loosely speaking, non-frame
> widgets). If you later decide you need more nested frames to get
> things right you only have to add the frames and adjust the packing,
> you don't have to go and rename all your buttons, entry widgets and so
> on throughout your code.


I typically do something "in between" like this:

set container [frame .container]
set row1 [frame $container.row1]
set r1c1 [frame $row1.column1]
...
set b [button $r1c1.button1]
pack $b

That way, if I need to move the button or add more layers of nesting, I
just need to change the path variable.

--
Glenn Jackman
Write a wise saying and your name will live forever. -- Anonymous

Neil Madden

unread,
Oct 29, 2008, 12:41:32 PM10/29/08
to

[grid] would definitely be my advice here. I rarely use [pack] these
days, except for very simple layouts (i.e. just one or two widgets).
Also look at grid column/rowconfigure commands.

-- Neil

tunity

unread,
Oct 29, 2008, 3:21:11 PM10/29/08
to tun...@yahoo.com
On Oct 29, 9:23 am, "Gernot Frisch" <m...@privacy.net> wrote:
> I want to pack my widgets like this:
> [A][ B ][C]
>
> And then I want a "command" that says: start a new line, thus create this:
>
> [A][ B ][C]
> [ D ][ E ]
> [ F ]
>
> (How) can I do this?


If you must use pack, other posters have shown how to do it. If not,
check out grid command. It is very flexible. As a matter of fact,
there was an entire GUI generation tool called SpecTcl which was based
on grid.


Gernot Frisch

unread,
Oct 30, 2008, 11:52:03 AM10/30/08
to

>> And then I want a "command" that says: start a new line, thus create
>> this:
>>
>> [A][ B ][C]
>> [ D ][ E ]
>> [ F ]
>>
>> (How) can I do this?
>
>
> If you must use pack, other posters have shown how to do it. If not,
> check out grid command. It is very flexible. As a matter of fact,
> there was an entire GUI generation tool called SpecTcl which was based
> on grid.

Yes, I want pack, and yes, it works great with the frames.

0 new messages