tcarmeli has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use Tk; use Tk::Pane; my $sc; my $x; my $i; my $j; my $box; my $mw = MainWindow->new; my $frame = $mw->Scrolled("Frame", -scrollbars => 'osoe', -sticky => 'nsew', -bg => 'black', -width => 900, -height => 500 )->pack(qw/-expand 1 -fill both/); foreach $i (0 .. 1) { $frame->Label( -text => $i, -relief => 'groove', -font => "{Arial} 15 bold", -borderwidth => 2, )->grid( -row => 0, -sticky=>"nsew", -column => $i, ); foreach $j (1 .. 4) { $sc = $frame->Canvas( -width => 400, -height => 125, -background => randColor() )->grid( -row => $j, -sticky => "nsew", -column => $i, ); $x = randNumber(); $box = $sc->createRectangle($x, 50, $x+20, 90, -fill => randColor(), -outline => 'black', -width => 2, -tags => 'rect', ); $sc->createLine( 10,100, 790,100, -arrow => 'last'); for($x=50;$x<800;$x+=50){ $sc->createLine( $x,95, $x,105 ); } } } MainLoop; sub randColor { my @colors = qw(red yellow blue orange green purple cyan pink); return $colors[rand($#colors + 1)]; } sub randNumber { my ($max, $min) = (350, 50); my $size = int(rand($max)); $size += $min if $size < $min; return $size; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk:: How to do a pane which scrolls partially
by zentara (Cardinal) on Nov 15, 2006 at 16:15 UTC | |
|
Re: Tk:: How to do a pane which scrolls partially
by mikasue (Friar) on Nov 16, 2006 at 14:25 UTC | |
by tcarmeli (Beadle) on Nov 20, 2006 at 07:50 UTC |