#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = new MainWindow(); $mw->geometry("600x400+200+200"); my $topframe = $mw->Frame(-bg=>'grey65')->pack(); my $infolab = $topframe->Label(-text =>'Some Info')->pack(); my $midframe = $mw->Frame(-bg=>'grey85')->pack(); my $midframel = $midframe->Frame(-bg=>'grey85')->pack(-side=>'left',-e +xpand=>1,-fill=>'y'); my $midframer = $midframe->Frame(-bg=>'grey85')->pack(-side=>'right'); my $botframe = $mw->Frame(-bg=>'grey85')->pack(); my $canvast = $midframer->Canvas( -bg =>'lightyellow', -width=>24000, -height=>25, -scrollregion=>[0,0,25000,1000], -xscrollincrement => 1, ) ->pack(-side=>'top'); my $canvasp = $midframer->Scrolled('Canvas', -bg =>'lightseagreen', -width=>24000, -height=>1000, -scrollregion=>[0,0,25000,1000], -scrollbars=>'se', #use the xscrollcommand in the subwidget instead # -xscrollcommand => \&xscrollit, -xscrollincrement => 1, -yscrollincrement => 1, ) ->pack(-side=>'bottom',-fill=>'both'); my $canvass = $midframel->Canvas( -bg =>'lightsteelblue', -width=>50, -height=>1000, -scrollregion=>[0,0,50,1000], -yscrollincrement => 1, ) ->pack(-side=>'top',-fill=>'both'); my $xscroll = $canvasp->Subwidget("xscrollbar"); my $yscroll = $canvasp->Subwidget("yscrollbar"); $xscroll->configure(-troughcolor =>'white', -activebackground =>'black', -command => \&xscrollit, ); $yscroll->configure(-troughcolor =>'white', -activebackground =>'black', -command => \&yscrollit, ); #create timebar and markers for(0..24000){ if( $_ % 100 == 0){ $canvast->createLine($_,0,$_,10); $canvast->createText($_,20,-text=>$_); next; } } for(0..24000){ if( $_ % 100 == 0){ $canvasp->createLine($_,0,$_,10); $canvasp->createText($_,20,-text=>$_); next; } } #create station boxes for(0..50){ $canvass->createRectangle(0,25+ $_*50, 50, 75 + $_*50, -fill =>'hotpink', ); } MainLoop; ###################################################################### +# sub xscrollit{ my $fraction = $_[1]; print "$fraction\n"; $canvast->xviewMoveto($fraction); $canvasp->xviewMoveto($fraction); } ###################################################################### sub yscrollit{ my $fraction = $_[1]; print "$fraction\n"; $canvass->yviewMoveto($fraction); $canvasp->yviewMoveto($fraction); } ######################################################################
In reply to Re: Tk:: How to do a pane which scrolls partially
by zentara
in thread Tk:: How to do a pane which scrolls partially
by tcarmeli
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |