buzzthebuzzsaw has asked for the wisdom of the Perl Monks concerning the following question:
Hi All,
Hoping this is a quick one, but I've run into a problem with a Scrolled Pane.
The Pane has a number of entry boxes added to it after the window is created which are larger than the pane can contain and so the scroll bars come into play. Ideally the pane should extend to not require the scrollbars unless the user manually reduces it.
I had planned to get the full width of the scrollbar and then make the pane that width, but I can't figure out how to get the information from the scrollbar subwidget from the Scrolled Pane.
Does anyone know how to get the full scrollregion of a scrollbar placed by Scrolled?
Failing that, the full width of a widget where it's scrolled and sections of it aren't viewable?
Thanks for any help anyone has!
BTB.
I've created some code below to demonstrate the problem. When the program is run it creates the two panes, but the left pane has the scrollbar already in place.
Clicking the button adds new widgets to the left pane and this is where I'd like the sash in the middle to be moved to accommodate the new fields.
How do I modify the width of the left pane so there's no scrollbar required unless it's manually modified by the user?
use strict; use warnings; use Tk; use Tk::Pane; my $mw = MainWindow->new; my($create_fields_num)=5; my($paned_win) = $mw->Panedwindow(-showhandle => 1); $paned_win->pack(-side => 'top', -expand => 1, -fill => 'both'); my($l_pane) = $paned_win->Scrolled('Pane', -scrollbars => 'osoe', -sticky => 'new' )->pack(-side => 'top', -anchor => 'nw', -expand => 1, -fill => 'both' +); my($lab_entry) = $l_pane->LabEntry( -label => "Enter Num:", -labelPack => [-side => 'left', -anchor => 'w'], -textvariable => \$create_fields_num )->pack(-side => 'top', -anchor => 'n', -fill => 'x'); $l_pane->Button( -text => 'Create Fields', -command => [\&create_fields, $l_pane, \$create_fields_num] )->pack(-side => 'top', -anchor => 'n', -fill => 'x'); my($r_pane) = $paned_win->Scrolled('Pane', -scrollbars => 'osoe', -sticky => 'new' )->pack(-side => 'top', -anchor => 'nw', -expand => 1, -fill => 'both' +); $paned_win->add($l_pane, $r_pane); MainLoop; sub create_fields{ my($l_pane, $fields) = @_; for(my $field_num; $field_num < $$fields; $field_num++){ $l_pane->Entry()->pack(-side => 'left'); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Tk Scrolled Width Question
by kcott (Archbishop) on Nov 11, 2015 at 02:44 UTC | |
by buzzthebuzzsaw (Acolyte) on Nov 11, 2015 at 15:12 UTC | |
|
Re: Perl Tk Scrolled Width Question
by stevieb (Canon) on Nov 10, 2015 at 22:35 UTC | |
by buzzthebuzzsaw (Acolyte) on Nov 11, 2015 at 15:03 UTC | |
|
Re: Perl Tk Scrolled Width Question
by Anonymous Monk on Nov 11, 2015 at 01:12 UTC | |
|
Re: Perl Tk Panedwindow Pane Width Sash Position
by Anonymous Monk on Nov 12, 2015 at 03:12 UTC | |
by buzzthebuzzsaw (Acolyte) on Nov 12, 2015 at 13:50 UTC | |
by Anonymous Monk on Nov 13, 2015 at 01:12 UTC | |
by buzzthebuzzsaw (Acolyte) on Nov 13, 2015 at 17:40 UTC |