popp0102 has asked for the wisdom of the Perl Monks concerning the following question:
use Tk; use strict; use warnings;
###Configurable Variables### my $pixel_size = 20; my $window_width = 1800; my $window_height = 1000;
#####create the Main Window##### my $mw = new MainWindow(-title => "BACnet Brush 1.0"); $mw -> geometry("1800x1000"); #resize the main window
#####Clear Button##### # This button clears the screen my $clear_button = $mw -> Button(-text => "Clear",-command => \&clear) + -> place(-x => $window_width*.5, -y => $window_height*.05);
#####create the canvas##### my $canv_width = .75*$window_width; my $canv_height = .8*$window_height; my $canvas = $mw -> Canvas(-width => $canv_width, -height => $canv_hei +ght, -relief => "sunken"); $canvas -> place(-x => .1*$window_width, -y => .1*$window_height);
#####creating the pixel grid on the canvas##### #pixel size> my $pixel_width = $pixel_size;> my $pixel_height = $pixel_size;>
#position variables for the grid> my $init_x = 0; my $init_y = 0; my $next_x = $pixel_width; my $next_y = $pixel_height;
#the pixel grid my @pixel_id; # this array stores all of the unique ids for each pixel $pixel_counter = 0; for(my $j = $init_y; $j < $canv_height; $j = $j + $pixel_height) { <for(my $i = $init_x; $i < $canv_width;$i = $i + $pixel_width) { $pixel_id[$pixel_counter] = $canvas -> createRectangle($init_x,$ +init_y,$next_x,$next_y,-fill => "white",-outline => "gray"); $init_x = $next_x; $next_x = $next_x + $pixel_width; $pixel_counter++; } $init_x = 0; $next_x = $pixel_width; $init_y = $next_y; $next_y = $next_y + $pixel_height; }
#####configuring the pixel grid #### for( my $k = 1; $k <= scalar(@pixel_id); $k++) { my $l = $k; $canvas->bind($k, "<M1-Enter>", sub { $canvas->itemconfigure($l, -fill => "blue"); }); }
##### Functions ##### ###Clear Function### sub clear { <$canvas -> itemconfigure('all', -fill => "white"); } MainLoop();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Event Recognition seems to be too slow
by jethro (Monsignor) on May 18, 2009 at 22:03 UTC | |
|
Re: Event Recognition seems to be too slow
by boblawblah (Scribe) on May 18, 2009 at 22:03 UTC | |
|
Re: Event Recognition seems to be too slow
by AnomalousMonk (Archbishop) on May 19, 2009 at 01:40 UTC | |
by popp0102 (Initiate) on May 19, 2009 at 20:42 UTC | |
|
Re: Event Recognition seems to be too slow
by BrowserUk (Patriarch) on May 20, 2009 at 00:15 UTC |