• pack/resize puzzle

    From Roger Critchlow@21:1/5 to All on Sun Dec 12 08:02:27 2021
    Hi Tclers --

    I run the following code in wish 8.6.11 on Ubuntu 21.10:

    . configure -background lightpink
    pack [frame .m -background lightgreen] -side top -expand true -fill x
    pack [button .m.b -text b] -side left
    pack [canvas .c -background lightblue] -side top -expand true -fill both

    It draws, as expected, a button bar and a canvas packed tight into the
    toplevel window.

    If I resize the toplevel window horizontally, the button bar and canvas grow to fill the available size, as is expected.

    If I resize the toplevel window vertically, the button bar and canvas do not grow to fill the available size. The canvas grows some and the button bar gets centered in the remaining vertical space.

    The expected behavior is that the button bar and canvas continue to tightly pack the toplevel window no matter how the window is resized.

    I've tried setting -ipady and -pady explicitly.

    I can use -anchor n and -anchor s to move the button bar to the top or bottom of the extra vertical space.

    I've switched between the default Wayland desktop and the 'Xorg' desktop.

    Why is this happening and how do I work around whatever is causing it?

    Thanks for any clues,

    -- rec --

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Werner@21:1/5 to All on Sun Dec 12 08:42:33 2021
    Why is this happening and how do I work around whatever is causing it?

    Do you really want the frame .m to expand?

    HTH,
    Christian

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From nemethi@21:1/5 to All on Sun Dec 12 19:02:40 2021
    Am 12.12.21 um 17:02 schrieb Roger Critchlow:
    Hi Tclers --

    I run the following code in wish 8.6.11 on Ubuntu 21.10:

    . configure -background lightpink
    pack [frame .m -background lightgreen] -side top -expand true -fill x
    pack [button .m.b -text b] -side left
    pack [canvas .c -background lightblue] -side top -expand true -fill both

    It draws, as expected, a button bar and a canvas packed tight into the toplevel window.

    If I resize the toplevel window horizontally, the button bar and canvas grow to fill the available size, as is expected.

    If I resize the toplevel window vertically, the button bar and canvas do not grow to fill the available size. The canvas grows some and the button bar gets centered in the remaining vertical space.

    The expected behavior is that the button bar and canvas continue to tightly pack the toplevel window no matter how the window is resized.

    I've tried setting -ipady and -pady explicitly.

    I can use -anchor n and -anchor s to move the button bar to the top or bottom of the extra vertical space.

    I've switched between the default Wayland desktop and the 'Xorg' desktop.

    Why is this happening and how do I work around whatever is causing it?

    Thanks for any clues,

    -- rec --


    Since you packed the frame .m using "-side top", the with of the parcel allocated for it will be in sync with that of its cavity, i.e., with the
    width of ".". From this it follows that specifying "-expand true" for
    .m means: "expand its parcel vertically whenever there is extra vertical
    space for it". Consequently, in order to get the desired behavior, you
    will have to pack this frame without specifying "-expand true". The
    "-fill x" remains necessary here, but it works independently of -expand.

    --
    Csaba Nemethi https://www.nemethi.de mailto:csaba.nemethi@t-online.de

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roger Critchlow@21:1/5 to nemethi on Sun Dec 12 12:20:30 2021
    On Sunday, December 12, 2021 at 1:02:44 PM UTC-5, nemethi wrote:
    Am 12.12.21 um 17:02 schrieb Roger Critchlow:
    [ ... ]

    Since you packed the frame .m using "-side top", the with of the parcel allocated for it will be in sync with that of its cavity, i.e., with the width of ".". From this it follows that specifying "-expand true" for
    .m means: "expand its parcel vertically whenever there is extra vertical space for it". Consequently, in order to get the desired behavior, you
    will have to pack this frame without specifying "-expand true". The
    "-fill x" remains necessary here, but it works independently of -expand.


    That's it! The -expand true is unnecesary for the button bar frame. Thank you very much!

    -- rec --

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gerald Lester@21:1/5 to Roger Critchlow on Sun Dec 12 20:41:14 2021
    On 12/12/21 2:20 PM, Roger Critchlow wrote:
    On Sunday, December 12, 2021 at 1:02:44 PM UTC-5, nemethi wrote:
    Am 12.12.21 um 17:02 schrieb Roger Critchlow:
    [ ... ]

    Since you packed the frame .m using "-side top", the with of the parcel
    allocated for it will be in sync with that of its cavity, i.e., with the
    width of ".". From this it follows that specifying "-expand true" for
    .m means: "expand its parcel vertically whenever there is extra vertical
    space for it". Consequently, in order to get the desired behavior, you
    will have to pack this frame without specifying "-expand true". The
    "-fill x" remains necessary here, but it works independently of -expand.


    That's it! The -expand true is unnecesary for the button bar frame. Thank you very much!

    For most people, gird tends to be more intuitive and easier to get the
    behavior correct.


    --
    +----------------------------------------------------------------------+
    | Gerald W. Lester, President, KNG Consulting LLC |
    | Email: Gerald.Lester@kng-consulting.net | +----------------------------------------------------------------------+

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)