Then you can try something like this:
$mw->Scrollbar()->pack(-side => 'right', -fill => 'y');
And then you can associate it with any widget.
Check out:
PerlTK
Njoi
| [reply] [d/l] |
Thanks!!
Can i associate frames with the scrollbar? If yes then How?
Also there are multiple frames, how can I associate the scrollbar with all of them?
| [reply] |
If you want to control the bindings of your scrollbars manually, it is a PITA full of details. Here is a decent example
However, if you don't need the same scrollbar linking multiple widgets, you usually just use a scrolled Pane, and add frames to the scrolled Pane, then addwhatever you want to the Frames. Like:
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use Tk::Pane;
my $mw = tkinit;
my $spane = $mw->Scrolled('Pane',
-scrollbars => 'osoe',
-bg => 'blue',
)->pack(-expand => 1, -fill => 'both');
# create 2 frames side by side in the pane, and fill with more frames
my $lframe = $spane->Frame(-bg=>'red')->pack(-side=>'left',-padx=>3);
my $rframe = $spane->Frame(-bg=>'red')->pack(-side=>'right',-padx=>3);
my %frames;
for(1..100){
$frames{$_}{'frame'} = $lframe->Frame()->pack(-pady => 5 );
$frames{$_}{'label'} = $frames{$_}{'frame'}->Label(-text=>'Frame '.$
+_)->pack;
my $num = $_;
$frames{$_}{'button'} = $frames{$_}{'frame'}->Button(
-text=>'Button '.$_,
-command => sub{print "$num pressed\n"},
)->pack;
}
for(101..200){
$frames{$_}{'frame'} = $rframe->Frame()->pack(-pady => 5 );
$frames{$_}{'label'} = $frames{$_}{'frame'}->Label(-text=>'Frame '.$
+_)->pack;
my $num = $_;
$frames{$_}{'button'} = $frames{$_}{'frame'}->Button(
-text=>'Button '.$_,
-command => sub{print "$num pressed\n"},
)->pack;
}
MainLoop;
| [reply] [d/l] [select] |
Check the same documentation. A frame is just another widget... You can link different type of widgets to scrolled.
So that should not be a problem for you.
If it doesn't work, You can always go back to Scrolled method for doing the same.
| [reply] |