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'); } }

In reply to Perl Tk Scrolled Width Question by buzzthebuzzsaw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.