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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.