panedwindow
La curiosité n’est pas un vilain défaut mais une qualité fondamentale.
Exemple minimal (testé OK en 8.4.13) :
set monpw [panedwindow .monpw -cursor X_cursor -showhandle true]
pack $monpw -expand true -fill both
set fGauche [frame .fGauche]
button $fGauche.bGros -text "Gros" -width 20
pack $fGauche.bGros
$monpw add $fGauche
set fDroite [frame .fDroite]
button $fDroite.bPetit -text "Petit"
pack $fDroite.bPetit
$monpw add $fDroiteExemple de ce qui NE MARCHE PAS (8.4.13) :
set fGauche [frame .fGauche]
button $fGauche.bGros -text "Gros" -width 20
pack $fGauche.bGros
set monpw [panedwindow .monpw -cursor X_cursor -showhandle true]
pack $monpw -expand true -fill both
$monpw add $fGauche
set fDroite [frame .fDroite]
button $fDroite.bPetit -text "Petit"
pack $fDroite.bPetit
$monpw add $fDroiteIci, c'est la déclaration de la frame AVANT le panedwindow qui pose problème. La commande add du paned window prend bien en compte la taille du gros bouton. Mais rien n'est affiché. on peut vérifier que, sur la zone gauche, c'est le curseur X qui s'affiche (=> .fGauche et bGros bien absents).
Voici un exemple un peu plus complet avec des widgets 8.4 . Sa structure permet un remplacement simple de la liste à charger dans la variable opts par la structure foreach afin de tester des options du widget :
wm minsize . 400 400
set wc 1
foreach opts {
{-showhandle true -orient horizontal -background pink -opaqueresize true -height 200 -width 800}
{-showhandle false -orient vertical -background blue -relief raised}
{-showhandle true -orient horizontal -background green -heigh 50 -sashcursor clock}
} {
set pw [eval panedwindow .pw_$wc $opts]
$pw add [labelframe .a_$wc -text Gauche] [labelframe .b_$wc -text Centre] [labelframe .c_$wc -text Droite]
incr wc
pack $pw -fill both -expand yes
set previous [lindex [$pw panes] end]
foreach pane [$pw panes] {
label $pane.l -text Orientation
pack $pane.l -fill both -expand yes
button $pane.b -text $pane -relief raised -borderwidth 2 -command [list $pw paneconfigure $pane -before $previous]
pack $pane.b -fill both -expand yes
spinbox $pane.sb -values "Gauche Centre Droite"
pack $pane.sb -fill both -expand yes
set previous $pane
}
}
En cliquant sur le bouton .c_X , on doit voir circuler les éléments gérés par le panedwindow.