in reply to Re^2: Tk autosizing Scrolled widgets
in thread Tk autosizing Scrolled widgets
The mixing of ->pack and ->grid only applies within ONE parent, different parents can have different geometry managers within one application. No Problem. I do it all the time. Example follows.
#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11136705 use warnings; use Tk; use Tk::Pane; my $mw = MainWindow->new(); $mw->geometry("+0+0"); $mw->maxsize(1000,1200); $mw->minsize(400,300); my $scroll = $mw->Scrolled('Pane', -scrollbars => 'osoe', -sticky => 'news', )->pack(-expand => 1, -fill => 'both'); my $f = $scroll->Frame->pack(-expand => 1, -fill => 'both'); foreach my $row (0..10) { foreach my $col (0..12) { $f->Entry( -text => "rc $row $col", -width => 0, )->grid(-row => $row, -column => $col, -sticky => 'news'); $row or $f->gridColumnconfigure($col, -weight => 1); } $f->gridRowconfigure($row, -weight => 1); } # example of ->pack in a different Frame my $buttonbar = $mw->Frame(-bg => 'blue', )->pack(-fill => 'x'); $buttonbar->Button(-text => 'Exit', -command => sub{$mw->destroy}, )->pack(-side => 'right', -fill => 'x', -expand => 1); $buttonbar->Button(-text => ' Another Noop', )->pack(-side => 'right', -fill => 'x', -expand => 1); $buttonbar->Button(-text => 'Noop', )->pack(-side => 'right', -fill => 'x', -expand => 1); MainLoop; -M $0 < 0 and exec $0; # FIXME for testing
Applications resizing themselves without user input is a BAD IDEA. Just imagine your user trying to click on something and having it move out of the way just
before the click. BAD IDEA!
See the "widget" demo program for an example of what an HList looks like. It should have come with the Perl/Tk package.
"I do not think it means what you think it means."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Tk autosizing Scrolled widgets
by olgo (Sexton) on Sep 14, 2021 at 13:43 UTC | |
by tybalt89 (Monsignor) on Sep 14, 2021 at 16:01 UTC |