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

How to use "place" on "ttk::frame" and specify width

29 views
Skip to first unread message

Alexandru

unread,
Jul 8, 2021, 5:46:26 AM7/8/21
to
Hi,

How can I use "place" on a "ttk::frame" with some content and specify width of the frame?

The -width option has no effect, I guess because the geometry manager takes precedence over this option.

In the manual on ttk::frame I found:

"Note that if the pack, grid, or other geometry managers are used to manage the children of the frame, by the GM's requested size will normally take precedence over the frame widget's -width and -height options. pack propagate and grid propagate can be used to change this."

It writes nothing about "place". What would be the procedure with "place" to turn the geometry manager off?

Many thanks
Alexandru

Ralf Fassel

unread,
Jul 8, 2021, 8:50:09 AM7/8/21
to
* Alexandru <alexandr...@meshparts.de>
| How can I use "place" on a "ttk::frame" with some content and specify width of the frame?
| The -width option has no effect, I guess because the geometry manager takes precedence over this option.

It does here;

% info patchlevel
8.6.11
% ttk::frame .f1 -borderwidth 2 -relief groove -width 100 -height 100
% ttk::frame .f2 -borderwidth 2 -relief groove -width 200 -height 200
% place .f1 -x 0 -y 0
% place .f2 -x 200 -y 200

shows two frames, one twice the dimensions of the other.

Mind to show your code?

HTH
R'

Alexandru

unread,
Jul 8, 2021, 9:03:52 AM7/8/21
to
I just extended your code with two lines. The key lies in putting something inside the frames. Then, the geometry manager takes over the frame dimensions, as descrobed in the docu.
On the other side, the manual does not show how to handle the "place" problem.

ttk::frame .f1 -borderwidth 2 -relief groove -width 100 -height 100
ttk::frame .f2 -borderwidth 2 -relief groove -width 200 -height 200
pack [ttk::button .f1.b1 -text "Button"]
pack [ttk::button .f2.b1 -text "Button"]
place .f1 -x 0 -y 0

Rich

unread,
Jul 8, 2021, 10:03:05 AM7/8/21
to
Alexandru <alexandr...@meshparts.de> wrote:
> Hi,
>
> How can I use "place" on a "ttk::frame" with some content and specify
> width of the frame?
>
> The -width option has no effect, I guess because the geometry manager
> takes precedence over this option.

Which -width option? The one for ttk::frame, or the -width option for
place?

Using place's -width/-height everything seems to work:

$ rlwrap wish
% # borderwidth and relief to make the empty frame 'visible'
% ttk::frame .f -borderwidth 2 -relief solid
.f
% wm geometry . 800x600
% # . window is now 800x600
% place .f -x 20 -y 20 -width 100 -height 100
% # a black frame border of 100x100 pixels appears, offset by 20 pixels
% # from the left and top

Rich

unread,
Jul 8, 2021, 10:05:44 AM7/8/21
to
man place:

...
-height size
Size specifies the height for window in screen units (i.e.
any of the forms accepted by Tk_GetPixels). The height will be
the outer dimension of window including its border, if any. If
size is an empty string, or if no -height or -relheight option is
specified, then the height requested internally by the window
will be used.
...
-width size
Size specifies the width for window in screen units (i.e. any of
the forms accepted by Tk_GetPixels). The width will be the outer
width of window including its border, if any. If size is an
empty string, or if no -width or -relwidth option is specified,
then the width requested internally by the window will be used.

...

Try telling [place] the width (and height if need be) that you want it
to enforce on the window. What happens then?

Alexandru

unread,
Jul 8, 2021, 4:08:57 PM7/8/21
to
You made my day. Thanks! It can be so simple if you look in the right place.
Regards
Alexandru
0 new messages