olgo has asked for the wisdom of the Perl Monks concerning the following question:
Greetings! Is there a way of getting a Tk Scrolled (Subwidget) Pane to automatically resize up to a limit (typically screen limitations)? It seems the dimensions of the Tk Scrolled widget needs to be specified explicitly, either when defining the widget or later using -configure(). I would want my main window and all contained widgets to expand with my dynamically defined Scrolled widget contents, and the scrollbars appear only when there is no place left to expand. Using Strawberry 5.32 on a Win32 system.
use Tk; use Tk::HList; use Tk::Pane; use strict; my $Window = MainWindow->new(); $Window->geometry("+0+0"); $Window->maxsize(1000,1200); $Window->minsize(400,300); my $tab = $Window; my $scroll = $tab->Scrolled('Pane', -sticky => 'news', -scrollbars => 'osoe', ); $scroll->pack; my $pane = $scroll->Subwidget("scrolled"); my $grid = $pane->HList( -columns => 13, -width => 0, # Causes scrollbar to appear -height => 0 # Causes scrollbar to appear ); $grid->pack(); $scroll->pack(-expand => 1, -fill => 'both'); foreach my $row (0..10) { $grid->addchild(""); foreach my $col (0..12) { my $wid = $grid->Entry( -text => "Whatever", -width => 0, ); $wid->pack; $grid->itemCreate ($row, $col, -itemtype => 'window', -widget => $wid); } } #$pane->configure(-height => '1000', -width => '1000'); # Works, but s +hould be handled by pack MainLoop;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Tk autosizing Scrolled widgets
by kcott (Archbishop) on Sep 13, 2021 at 11:53 UTC | |
by olgo (Sexton) on Sep 13, 2021 at 13:18 UTC | |
Re: Tk autosizing Scrolled widgets
by tybalt89 (Monsignor) on Sep 13, 2021 at 23:29 UTC | |
by Marshall (Canon) on Sep 13, 2021 at 23:44 UTC | |
Re: Tk autosizing Scrolled widgets
by Marshall (Canon) on Sep 13, 2021 at 22:23 UTC | |
by olgo (Sexton) on Sep 14, 2021 at 06:46 UTC | |
by tybalt89 (Monsignor) on Sep 14, 2021 at 08:41 UTC | |
by olgo (Sexton) on Sep 14, 2021 at 13:43 UTC | |
by tybalt89 (Monsignor) on Sep 14, 2021 at 16:01 UTC |