Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

A few hours grace before the madness begins again.


comp / comp.lang.tcl / Re: pack or grid (or the other way around)?

SubjectAuthor
* pack or grid (or the other way around)?Luc
+* Re: pack or grid (or the other way around)?Rich
|`- Re: pack or grid (or the other way around)?Schelte
`* Re: pack or grid (or the other way around)?Ralf Fassel
 `* Re: pack or grid (or the other way around)?Luc
  `* Re: pack or grid (or the other way around)?Rich
   `- Re: pack or grid (or the other way around)?Robert Heller

1
Subject: pack or grid (or the other way around)?
From: Luc
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Thu, 16 Jan 2025 02:56 UTC
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: pack or grid (or the other way around)?
Date: Wed, 15 Jan 2025 23:56:11 -0300
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <20250115235611.5613ef18@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 16 Jan 2025 03:56:13 +0100 (CET)
Injection-Info: dont-email.me; posting-host="89410c0664fbbc40dba5737542bc538e";
logging-data="3394172"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/kdk4i4rJBO7zp5k51jDCSUoikx2RX0xE="
Cancel-Lock: sha1:6bWaXb+7dc5v+Ou76Vj/C3DkrlY=
View all headers

I am working on a package that I guess would be considered a megawidget
and I vaguely remember reading somewhere that widgets (or was it
applications?) that use pack cannot contain widgets that use grid, or
maybe it was the other way around, which means that if my megawidget
uses pack, nobody would be able to use it inside another widget (or
would that be an application?) that already uses grid, or maybe the
other way around, well, you get the idea.

I also vaguely remember reading that "the other way around" was safe
though, that is, one between pack and grid may contain widgets managed
by the other geometry manager.

Is that correct? I can't seem to find that exact information. I guess
I really need to be sure before I make a commitment to either one
(or the other way around).

--
Luc
>>

Subject: Re: pack or grid (or the other way around)?
From: Rich
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Thu, 16 Jan 2025 04:11 UTC
References: 1
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: pack or grid (or the other way around)?
Date: Thu, 16 Jan 2025 04:11:20 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 59
Message-ID: <vma0t8$3buad$1@dont-email.me>
References: <20250115235611.5613ef18@lud1.home>
Injection-Date: Thu, 16 Jan 2025 05:11:21 +0100 (CET)
Injection-Info: dont-email.me; posting-host="e883e0f3b2b433100952970dffbd380e";
logging-data="3537229"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+8YipDYP9FcB5zZR1jzVj"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:4A1kC+2Kumt2zoip0zOCeHet3Lw=
View all headers

Luc <luc@sep.invalid> wrote:
> I am working on a package that I guess would be considered a megawidget
> and I vaguely remember reading somewhere that widgets (or was it
> applications?) that use pack cannot contain widgets that use grid, or
> maybe it was the other way around, which means that if my megawidget
> uses pack, nobody would be able to use it inside another widget (or
> would that be an application?) that already uses grid, or maybe the
> other way around, well, you get the idea.
>
> I also vaguely remember reading that "the other way around" was safe
> though, that is, one between pack and grid may contain widgets managed
> by the other geometry manager.
>
> Is that correct? I can't seem to find that exact information. I guess
> I really need to be sure before I make a commitment to either one
> (or the other way around).

You seem to be getting something very mixed up.

The rule is that any single widget can only be managed by one "manager"
[1] and all the direct children within a widget have to all be managed
by the same manager (because the manager operates from the parent
widget). Plus you have to obey any additional required parent/child
relationships imposed by the managers (the manual pages will detail
these).

But you can very well nest gridded items inside packed items, or packed
items inside gridded items.

# a 'gridded' item managed by pack

label .l1 -text "Label 1"
label .l2 -text "Label 2"

frame .f1
label .f1.l3 -text "Label 3"
label .f1.l4 -text "label 4"

grid .f1.l3 .f1.l4

pack .l1 .f1 .l2 -side top

# a 'packed' item managed by grid

label .l1 -text "Label 1"
label .l2 -text "Label 2"

frame .f1
label .f1.l3 -text "Label 3"
label .f1.l4 -text "label 4"

pack .f1.l3 .f1.l4 -side top

grid .l1 .f1 .l2

[1] "manager" being one of 'pack', 'place', or 'grid'.

Subject: Re: pack or grid (or the other way around)?
From: Ralf Fassel
Newsgroups: comp.lang.tcl
Date: Thu, 16 Jan 2025 10:34 UTC
References: 1
Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: pack or grid (or the other way around)?
Date: Thu, 16 Jan 2025 11:34:34 +0100
Lines: 28
Message-ID: <ygabjw7cait.fsf@akutech.de>
References: <20250115235611.5613ef18@lud1.home>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net ZqRyTKqs6TEMkTKYAFCXpQP1H6q19ic/bw1pqCQVUEJPsyTVA=
Cancel-Lock: sha1:a4xEFAXXO9oqXNiB/onzs4orpEw= sha1:b7r2dzh2XffCMRZRoT8SJGrpS1A= sha256:8pxN/RNkpdQmN4boDzeEqX2ZDHCMcF/Fs8SKOVln8y0=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
View all headers

* Luc <luc@sep.invalid>
| I am working on a package that I guess would be considered a megawidget
| and I vaguely remember reading somewhere that widgets (or was it
| applications?) that use pack cannot contain widgets that use grid, or
| maybe it was the other way around, which means that if my megawidget
| uses pack, nobody would be able to use it inside another widget (or
| would that be an application?) that already uses grid, or maybe the
| other way around, well, you get the idea.

In addition to what Rich wrote, here is what you *cant* do:

frame .f
label .f.l1
label .f.l2

pack .f.l1
grid .f.l2
=> error: cannot use geometry manager grid inside .f which already has slaves managed by pack

grid .f.l2
pack .f.l1
=> error: cannot use geometry manager pack inside .f which already has slaves managed by grid

But .f itself can be managed by either grid or pack, regardless of what
you use to pack/grid widgets 'inside' .f

HTH
R'

Subject: Re: pack or grid (or the other way around)?
From: Luc
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Thu, 16 Jan 2025 20:31 UTC
References: 1 2
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: pack or grid (or the other way around)?
Date: Thu, 16 Jan 2025 17:31:20 -0300
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <20250116173120.2b7f2d0d@lud1.home>
References: <20250115235611.5613ef18@lud1.home>
<ygabjw7cait.fsf@akutech.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 16 Jan 2025 21:31:21 +0100 (CET)
Injection-Info: dont-email.me; posting-host="ba743edcb2226c5d6922b61a413fb962";
logging-data="3850076"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18YVGYD0gwiHeXVtWpjnJ1pM5DWaU9QqBw="
Cancel-Lock: sha1:dsnc/0tzkruNKSpYE7L9++yym5E=
View all headers

On Thu, 16 Jan 2025 11:34:34 +0100, Ralf Fassel wrote:

>In addition to what Rich wrote, here is what you *cant* do:
>
> frame .f
> label .f.l1
> label .f.l2
>
> pack .f.l1
> grid .f.l2
> => error: cannot use geometry manager grid inside .f which already has
> slaves managed by pack
>
> grid .f.l2
> pack .f.l1
> => error: cannot use geometry manager pack inside .f which already has
> slaves managed by grid
>
>But .f itself can be managed by either grid or pack, regardless of what
>you use to pack/grid widgets 'inside' .f
**************************

That is my concern.

> .f itself can be managed by either grid or pack, regardless of what
>you use to pack/grid widgets 'inside' .f

That's because .f is the parent.

Now suppose someone has an application that uses grid. Everything is
inside one big 'gridded' frame. And suppose my megawidget uses pack.

Or the other way around.

That is my concern.

I still haven't gone back to that code. I guess I will have to run
multiple tests on it and see what happens.

--
Luc
>>

Subject: Re: pack or grid (or the other way around)?
From: Rich
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Thu, 16 Jan 2025 20:52 UTC
References: 1 2 3
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: pack or grid (or the other way around)?
Date: Thu, 16 Jan 2025 20:52:50 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <vmbrj2$3ln8n$1@dont-email.me>
References: <20250115235611.5613ef18@lud1.home> <ygabjw7cait.fsf@akutech.de> <20250116173120.2b7f2d0d@lud1.home>
Injection-Date: Thu, 16 Jan 2025 21:52:56 +0100 (CET)
Injection-Info: dont-email.me; posting-host="e883e0f3b2b433100952970dffbd380e";
logging-data="3857687"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Y9EPWoFYCG6Jlr/kt1iDx"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:wz25vCywrSSSBxWnhQCz+dh4828=
View all headers

Luc <luc@sep.invalid> wrote:
> On Thu, 16 Jan 2025 11:34:34 +0100, Ralf Fassel wrote:
>
>>In addition to what Rich wrote, here is what you *cant* do:
>>
>> frame .f
>> label .f.l1
>> label .f.l2
>>
>> pack .f.l1
>> grid .f.l2
>> => error: cannot use geometry manager grid inside .f which already has
>> slaves managed by pack
>>
>> grid .f.l2
>> pack .f.l1
>> => error: cannot use geometry manager pack inside .f which already has
>> slaves managed by grid
>>
>>But .f itself can be managed by either grid or pack, regardless of what
>>you use to pack/grid widgets 'inside' .f
> **************************
>
> That is my concern.
>
>> .f itself can be managed by either grid or pack, regardless of what
>>you use to pack/grid widgets 'inside' .f
>
> That's because .f is the parent.
>
> Now suppose someone has an application that uses grid. Everything is
> inside one big 'gridded' frame. And suppose my megawidget uses pack.
>
> Or the other way around.
>
> That is my concern.

Provided your megawidget exposes only one single top level widget
(usually a frame which holds all the internal widgets) to the user of
the megawidget it will make no difference. The user of the megawidget
can do anything they like to the outer container as far as
pack/grid/placing it, zero impact on your bits and pieces inside that
container.

Subject: Re: pack or grid (or the other way around)?
From: Schelte
Newsgroups: comp.lang.tcl
Organization: KPN B.V.
Date: Thu, 16 Jan 2025 20:57 UTC
References: 1 2
Date: Thu, 16 Jan 2025 21:57:52 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: pack or grid (or the other way around)?
Newsgroups: comp.lang.tcl
References: <20250115235611.5613ef18@lud1.home> <vma0t8$3buad$1@dont-email.me>
Content-Language: en-US
From: nospam@wanadoo.nl (Schelte)
In-Reply-To: <vma0t8$3buad$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$2f80e801$261f1f62@df644f5ed2a2afd2>
Organization: KPN B.V.
Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!news.mixmin.net!feed.abavia.com!abe005.abavia.com!abp002.abavia.com!news.kpn.nl!not-for-mail
Lines: 41
Injection-Date: Thu, 16 Jan 2025 21:57:53 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
View all headers

On 16/01/2025 05:11, Rich wrote:
> The rule is that any single widget can only be managed by one "manager"
> [1] and all the direct children within a widget have to all be managed
> by the same manager (because the manager operates from the parent
> widget).

[snip]

> [1] "manager" being one of 'pack', 'place', or 'grid'.

Actually, the problem is that geometry propagation may only be done by
one manager. It is possible to use both grid and pack within a single
widget if you switch off propagation on one of the two. So this works
just fine (for some definition of working):

frame .f
pack .f -fill both -expand 1
pack propagate .f 0

label .f.l1 -text label1
label .f.l2 -text label2

pack .f.l1
grid .f.l2

The place manager never does any propagation, so it can be mixed with
any of the other two managers without extra precautions. In fact, I use
that on a regular basis to create a styled toplevel:

proc ttk::toplevel {w args} {
tk::toplevel $w {*}$args
place [ttk::frame $w.tilebg] -relwidth 1 -relheight 1
}

Even though the ttk::frame is managed by place, you can still pack or
grid other widgets inside the toplevel.

Schelte.

Subject: Re: pack or grid (or the other way around)?
From: Robert Heller
Newsgroups: comp.lang.tcl
Organization: Deepwoods Software
Date: Thu, 16 Jan 2025 23:42 UTC
References: 1 2
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: heller@deepsoft.com (Robert Heller)
Newsgroups: comp.lang.tcl
Subject: Re: pack or grid (or the other way around)?
Date: Thu, 16 Jan 2025 23:42:13 -0000 (UTC)
Organization: Deepwoods Software
Lines: 75
Message-ID: <vmc5gl$3ndsv$1@dont-email.me>
References: <20250115235611.5613ef18@lud1.home>
<ygabjw7cait.fsf@akutech.de> <20250116173120.2b7f2d0d@lud1.home>
<vmbrj2$3ln8n$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Injection-Date: Fri, 17 Jan 2025 00:42:14 +0100 (CET)
Injection-Info: dont-email.me; posting-host="08f7195a09c218d20fb43957dca38ff1";
logging-data="3913631"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+rSueQk7YLP40IINCmKEY50YzjDL5pJDM="
Cancel-Lock: sha1:4eKZES1NSE2PRBpDFB50d+gujcU=
In-Reply-To: <vmbrj2$3ln8n$1@dont-email.me>
Originator: heller@sharky5.deepsoft.com
X-Newsreader: TkNews 3.0 (1.2.18)
View all headers

At Thu, 16 Jan 2025 20:52:50 -0000 (UTC) Rich <rich@example.invalid> wrote:

>
> Luc <luc@sep.invalid> wrote:
> > On Thu, 16 Jan 2025 11:34:34 +0100, Ralf Fassel wrote:
> >
> >>In addition to what Rich wrote, here is what you *cant* do:
> >>
> >> frame .f
> >> label .f.l1
> >> label .f.l2
> >>
> >> pack .f.l1
> >> grid .f.l2
> >> => error: cannot use geometry manager grid inside .f which already has
> >> slaves managed by pack
> >>
> >> grid .f.l2
> >> pack .f.l1
> >> => error: cannot use geometry manager pack inside .f which already has
> >> slaves managed by grid
> >>
> >>But .f itself can be managed by either grid or pack, regardless of what
> >>you use to pack/grid widgets 'inside' .f
> > **************************
> >
> > That is my concern.
> >
> >> .f itself can be managed by either grid or pack, regardless of what
> >>you use to pack/grid widgets 'inside' .f
> >
> > That's because .f is the parent.
> >
> > Now suppose someone has an application that uses grid. Everything is
> > inside one big 'gridded' frame. And suppose my megawidget uses pack.
> >
> > Or the other way around.
> >
> > That is my concern.
>
> Provided your megawidget exposes only one single top level widget
> (usually a frame which holds all the internal widgets) to the user of
> the megawidget it will make no difference. The user of the megawidget
> can do anything they like to the outer container as far as
> pack/grid/placing it, zero impact on your bits and pieces inside that
> container.

Important gotcha: I *think* the OP is comtemplating packing (or gridding) his
megawidget. That would be bad practice. The widget (typically a frame)
should be returned unmanged. The caller of the function that creates the
megawidget is responsible for setting its geometry management:

proc Create-Some-Wonderful-MegaWidget {w args} {
# the frame for the MegaWidget
frame $w -class Megawidget
# pack an only child
pack [button $w.b -text "Useless Button" -command [list puts "who cares: $args"]]
# return the Megawidget
return $w
}

toplevel .foo
set w [Create-Some-Wonderful-MegaWidget .foo.bar]
grid $w

>
>
>
>

--
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
heller@deepsoft.com -- Webhosting Services

1

rocksolid light 0.9.8
clearnet tor