Discussion:
packed panedwindow doesn't fill as expected
(too old to reply)
Luc
2024-10-04 15:45:45 UTC
Permalink
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.
--
Luc
nemethi
2024-10-04 17:25:56 UTC
Permalink
Post by Luc
Of course, my expectations are often wrong.
-------------------------
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.
-------------------------
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:***@t-online.de
Loading...