#!/usr/bin/perl -w use strict; use Tk; use Tk::Canvas; use Getopt::Std; my $width = 250; my $height = 250; my $units = 10; my $background = 'blue'; my $fill = 'yellow'; my %opts = (); getopts( 'W:H:b:f:u:h', \%opts ); if( $opts{W} ) { $width = $opts{W} ; } if( $opts{H} ) { $height = $opts{H} ; } if( $opts{b} ) { $background = $opts{b} ; } if( $opts{f} ) { $fill = $opts{f} ; } if( $opts{u} ) { $units = $opts{u} ; } my $dx = $width / $units; my $dy = $height / $units; my $top = MainWindow->new(); my $can = $top->Canvas( -width => $width, -height=> $height )->pack(); drawGrid( $can ); my $root = "BLAHBLAHBLAH"; $can->bind( \$can, '', \&my_test( $root ) ); MainLoop; sub drawGrid { my $can = shift; my $X=0; for ( my $x=0; $x < $units; $x++ ) { $can->create( 'line' , $X , 0 , $X , $can->reqheight() ); $X += $dx; } my $Y=0; for ( my $y=0; $y < $units; $y++ ) { $can->create( 'line' , 0 , $Y , $can->reqwidth() , $Y); $Y += $dy; } } sub my_test { my $msg = shift; print "$msg\n"; }