Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

i have a main window which has an entry, label & Optionmenu widgets in it. width of $mw is fixed and height is going to change depending on the number of items. so i wanted to add a scroll bar on right hand side. i am using the below code to add the scroll bar.
$mw->Scrolled('Pane',-scrollbars => 'e')->grid(-row=>1,-column=>9);
But i can see the scroll bar NOT expanded for a FULL $mw also it is INACTIVE. if am using the GRID manager how to define the scrollbar? does the scrollbar works only with pack() manager? with grid manager how do i control the scrollbar location?

Replies are listed 'Best First'.
Re: Scroll bar with Grid manager
by TGI (Parson) on Apr 05, 2007 at 17:47 UTC

    Some sample code would help a lot.

    It looks like your problem is that you are managing the widgets in $mw. You should be putting the widgets in the Pane (which is basically a scrolled frame).

    use strict; use warnings; use Tk; my $mw = MainWindow->new(-title => 'My Window'); $mw->Label( -text => 'Unscrolled Heading', )->pack( -fill => 'x', ); my $scrolled_frame = $mw->Scrolled( 'Frame', -scrollbars => 'e', )->pack( -expand => 1, -fill => 'both', ); foreach (1..100) { my $l = $scrolled_frame->Label( -text => "Label $_", ); my $om = $scrolled_frame->Optionmenu( -options => [1..100], -variable => \$_, ); my $e = $scrolled_frame->Entry( -text => "Entry $_", ); $l->grid( $om, $e, -sticky => 'ew', -padx => 5, -pady => 5, ); } MainLoop;


    TGI says moo