http://qs1969.pair.com?node_id=11128980


in reply to Controlling resize of Tk::Panedwindow

Hi

Try Tk::IDElayout it provides a https://metacpan.org/pod/Tk::IDEpanedwindow#expandfactors

Its not exactly perfect but try it out

#!/usr/bin/perl -- use strict; use warnings; use Tk; use Tk::IDEpanedwindow; my $main_window = MainWindow->new( -bg => 'black' ); my $top_container = $main_window->IDEpanedwindow( qw/-orient vertical -sashpad 1 -sashwidth 3 -sashrelief groove -bg red/); $top_container->pack( -side => 'top', -expand => 'yes', -fill => 'both', -padx => '2m', -pady => '2', ); my $world_container = $top_container->IDEpanedwindow( qw/-orient horizontal -sashpad 1 -sashwidth 3 -sashrelief groove -bg green / ); $world_container->pack( -side => 'top', -expand => 'yes', -fill => 'both', -padx => '2', -pady => '2m', ); $top_container->add( $world_container, -expandfactor, 1, ); my $world_view = $world_container->Canvas( -bg => 'orange' ); $world_view->pack( -side => 'left', -fill => 'both', -expand => 1, ); ## sometimes factor 3 is too much, sometimes not enough # $world_container->add($world_view , -expandfactor,3 ); $world_container->add( $world_view, -expandfactor, 10 ); my $entity_view = $world_container->Frame( -bg => 'blue', ); $entity_view->pack( -side => 'right', -fill => 'y', -expand => 0, ); $world_container->add( $entity_view, -expandfactor, 1, -minsize => 100 ); # SASH limits); my $control_view = $top_container->Frame( -bg => 'yellow', ); $control_view->pack( -side => 'bottom', -fill => 'x', -expand => 0, ); $top_container->add( $control_view, -expandfactor, 1, -minsize => 60 ); # SASH limits); my $quit_button = $control_view->Button( -text => 'Quit', # -command => sub { $main_window->destroy }, # -command => ['destroy', $main_window ], -command => 'exit', ); $quit_button->pack( -side => 'right', -expand => 'no', -pady => 2, ); $main_window->WidgetDump if @ARGV; Tk::MainLoop();

Panedwindow provides a minsize sash resizing limit, but IDEpanedwindow doesnt

Another thing to try is https://www.tcl.tk/man/tcl8.6/TkCmd/ttk_panedwindow.htm somehow, as it has a "weight" option,

which you can try by way of https://metacpan.org/pod/Tcl::pTk

but to me it seems to be similarly funky as expandfactors

Both can be made to do what you want but its fiddly , factors need to adjusted (factored) based on window size, and minimum sizes pre-set and enforced ... I leave that up to you

#!/usr/bin/perl -- use strict; use warnings; use Tcl::pTk::TkHijack; use Tk; my $main_window = MainWindow->new( -bg => 'black' ); my $int = $main_window->interp; # Get the intepreter that was created in the MainWindow call $int->Eval(<<'__TCL__'); ttk::panedwindow .top_container -orient vertical ttk::panedwindow .world_container -orient horizontal -height 100 ttk::style configure . -background black ## fail ttk::style configure .top_container -background red ttk::style configure .world_container -background green __TCL__ my $top_container = $int->widget('.top_container'); # fail #~ $top_container->configure(qw/-background red /); my $world_container = $int->widget('.world_container'); $top_container->pack( -side => 'top', -expand => 'yes', -fill => 'both', -padx => '2m', -pady => '2', ); $world_container->pack( -side => 'top', -expand => 'yes', -fill => 'both', -padx => '2', -pady => '2m', ); $top_container->add( $world_container, -weight, 2 ); my $world_view = $world_container->Canvas( -bg => 'orange' ); $world_view->pack( -side => 'left', -fill => 'both', -expand => 1, ); $world_container->add( $world_view, -weight, 30 ); my $entity_view = $world_container->Frame( -bg => 'blue', ); $entity_view->pack( -side => 'right', -fill => 'y', -expand => 0, ); $world_container->add( $entity_view, -weight, 2 ); my $control_view = $top_container->Frame( -bg => 'yellow', ); $control_view->pack( -side => 'bottom', -fill => 'x', -expand => 0, ); $top_container->add( $control_view, -weight, 2 ); my $quit_button = $control_view->Button( -text => 'Quit', -command => [ 'destroy', $main_window ], ); $quit_button->pack( -side => 'right', -expand => 'no', -pady => 2, ); Tk::MainLoop();

*) the labels ought to match the variable names (A B C does not match world_view...), its like labeling a red window orange