When you manually make Scrollbars, you must define what they do. Use a Tk::Scrolled widget if you want automatic scrolling. Sometimes, an short example is worth 10,000 words. See Re: I seek illumination and knowledge or
#!/usr/bin/perl
##########
use Tk;
use strict;
my $mw=tkinit;
my $c=$mw->Scrolled('Canvas',
-width=>400,
-height=>400,
-bg=>'red',
-scrollregion=>[0,0,1000,1000],
-scrollbars=>'se')->pack(-expand=>1, -fill=>'both');
$c->create('rect',&n) for (0..40);
my $id = $mw->repeat(100,sub{
$c->xviewScroll(1,'units');
$c->yviewScroll(1,'units');
});
$mw->after(10000, sub{$id->cancel});
MainLoop;
sub n
{
my ($x1,$y1) = ( rand(1000), rand(1000) );
my ($x,$y) = ($x1/2,$y1/2);
return ($x,$y,$x1,$y1);
}
| [reply] [Watch: Dir/Any] [d/l] |
use Tk;
my $mw = tkinit();
my $f = $mw->Scrolled( 'Frame' )->pack;
$f->Button ( -text=> $_ )->pack for ( 1..50 ) ;
$mw->WidgetDump;
$mw->MainLoop;
__END__
| [reply] [Watch: Dir/Any] [d/l] |
Thanks for reply, actually i have another piece of code that uses Tk::Scrolled, and it works perfectly ok… but i just like to give a try on Scrollbar, as its interf ace looks like i can "attach" a scroll bar after a widget is created, in contrast that a scroll widget wraps the real widget that i want to operate. Though, i am still learning how to read the GUI documentation at the same time.
| [reply] [Watch: Dir/Any] |