Sujet : Re: packed panedwindow doesn't fill as expected
De : csaba.nemethi (at) *nospam* t-online.de (nemethi)
Groupes : comp.lang.tclDate : 04. Oct 2024, 18:25:56
Autres entêtes
Message-ID : <vdp8f4$1v4kg$1@tota-refugium.de>
References : 1
User-Agent : Mozilla Thunderbird
Am 04.10.24 um 17:45 schrieb Luc:
Of course, my expectations are often wrong.
This code works perfectly as expected:
-------------------------
package require Tk
package require tile
wm withdraw .
set ::w [toplevel .topw]
wm resizable .topw 1 1
wm attributes .topw -zoomed 1
wm geometry .topw 600x100+0+0
bind $::w <Escape> {exit 0}
wm protocol $::w WM_DELETE_WINDOW {exit 0}
set ::outerframe [frame $w.outerframe -background "red" ]
pack $::outerframe -fill both -expand 1
set ::tabframe [frame $::outerframe.tabframe -background "blue"]
pack $::tabframe -fill both -expand 0 -ipadx 100 -ipady 0
set tabbutton [button $tabframe.tabbutton -text "Tab" -font "Freesans 12"]
pack $tabbutton -fill x -expand 0 -side left
set ::pathlineframe [frame $::outerframe.pathlineframe -background "black" -cursor "arrow" -bd 6]
pack $::pathlineframe -fill x -expand 1 -side top -anchor n
set ::pathline [entry $::pathlineframe.pathline -background "yellow" -font "Freesans 14" -bd 2]
pack $::pathline -fill x -expand 1 -side left -ipadx 100
set menubutton [button $::pathlineframe.menubutton -text "Menu" -font "Freesans 12"]
pack $menubutton
-------------------------
Now I want to fill up the entire red area (which is the super big master
"outer" frame which contains everything) with a panedwindow.
The panedwindow has pink background. Let's try:
-------------------------
package require Tk
package require tile
wm withdraw .
set ::w [toplevel .topw]
wm resizable .topw 1 1
wm attributes .topw -zoomed 1
wm geometry .topw 600x100+0+0
bind $::w <Escape> {exit 0}
wm protocol $::w WM_DELETE_WINDOW {exit 0}
set ::outerframe [frame $w.outerframe -background "red" ]
pack $::outerframe -fill both -expand 1
set ::tabframe [frame $::outerframe.tabframe -background "blue"]
pack $::tabframe -fill both -expand 0 -ipadx 100 -ipady 0
set tabbutton [button $tabframe.tabbutton -text "Tab" -font "Freesans 12"]
pack $tabbutton -fill x -expand 0 -side left
set ::pathlineframe [frame $::outerframe.pathlineframe -background "black" -cursor "arrow" -bd 6]
pack $::pathlineframe -fill x -expand 1 -side top -anchor n
set ::pathline [entry $::pathlineframe.pathline -background "yellow" -font "Freesans 14" -bd 2]
pack $::pathline -fill x -expand 1 -side left -ipadx 100
set menubutton [button $::pathlineframe.menubutton -text "Menu" -font "Freesans 12"]
pack $menubutton
set unipane [panedwindow $::outerframe.unipane]
pack $unipane -fill both -expand 1
$unipane configure -background "pink"
-------------------------
So the panedwindow is in right place, but how come it is not filling up
the entire available space? Isn't that what -fill both is supposed to do?
Sometimes it's really hard to understand pack. Then again, I don't
think grid is that easy either.
Both $::pathlineframe and $unipane are packed with "-expand 1". For this reason, the parcels of both widgets will be expanded to consume extra space in $::outerframe. Since the pack invocation for $::pathlineframe has "-fill x" rather than "-fill both", actually it doesn't need "-expand 1". By changing it to "-expand 0" (or simply removing it), $unipane will become the only expanding child of $::outerframe, hence it will fill the entire available space.
-- Csaba Nemethi https://www.nemethi.de mailto:csaba.nemethi@t-online.de