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

pack -in may not be used with a toplevel

48 views
Skip to first unread message

rick h

unread,
Oct 1, 2012, 9:15:53 PM10/1/12
to
Many of the examples document the use of pack -in with widget under the root window. However, the -in returns a "can't pack" error.

(bin) 49 % toplevel .mytop
.mytop
(bin) 50 % frame .mytop.f1
.mytop.f1
(bin) 51 % button .b1 -text Hello
.b1
(bin) 52 % pack .b1 -in .mytop.f1
can't pack .b1 inside .mytop.f1
(bin) 53 %

Would appreciate an explanation for appears to me as an inconsistency.

What am I not getting???!

Rick

Les Cargill

unread,
Oct 1, 2012, 9:32:37 PM10/1/12
to
Try this

console show
toplevel .mytop
frame .mytop.f1
pack .mytop.f1
button .mytop.f1.b1 -text Hello
pack .mytop.f1.b1 -in .mytop.f1

--
Les Cargill

Emiliano

unread,
Oct 2, 2012, 8:16:13 AM10/2/12
to
See the pack(n) man page, section "RESTRICTIONS ON MASTER WINDOWS".

Regards
Emiliano

rick h

unread,
Oct 2, 2012, 3:32:18 PM10/2/12
to
thanks for the reply, but...

the advantage of -in derives from not having to specify a hierarchy for the button widget.

According to the examples (many) that don't relate to a top level, one should be able to instantiate a button as:
button .b1 -text "Hello"

pack .b1 -in .mytop.f1

rick h

unread,
Oct 2, 2012, 3:39:57 PM10/2/12
to
Thanks for the fast reply, but...

Remove the toplevel option and it works. Is a toplevel not a master? that seems to be all that I can get out of it. The benefits of -in is the need not to specify a hierarchy...

Rick

Donal K. Fellows

unread,
Oct 2, 2012, 5:43:56 PM10/2/12
to
On 02/10/2012 20:39, rick h wrote:
> Thanks for the fast reply, but...
>
> Remove the toplevel option and it works. Is a toplevel not a master? that
> seems to be all that I can get out of it. The benefits of -in is the need
> not to specify a hierarchy...

While toplevels are perfectly suitable as masters, Tk also requires that
all things managed within a toplevel — directly or indirectly — be also
subwidgets of that toplevel. Formally, it requires that [winfo toplevel]
of both the slave and its master be the same. (Actually, it's a bit more
restricted than even that, but the difference there is rather technical
and doesn't matter for even vaguely sane layouts.)

Donal.

Les Cargill

unread,
Oct 2, 2012, 6:39:25 PM10/2/12
to
If you need to reinstantiate a button that is subject to hierarchy, just
( I haven't tried this, so there may be some irritating details )

button .mytop.f1.b1
.mytop.f1.b1 config [ .b1 config ]


> According to the examples (many) that don't relate to a top level, one should be able to instantiate a button as:
> button .b1 -text "Hello"
>
> pack .b1 -in .mytop.f1
>


That doesn't work. Do the other thing. :)

(Emiliano graciously even subset the man page where this is
covered ).

--
Les Cargill

rick h

unread,
Oct 2, 2012, 11:09:21 PM10/2/12
to
Thank you...
0 new messages