1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#!/usr/bin/perl use strict; use warnings; use Tk; my $scale_faktor = 1.5; my $window = MainWindow->new(); my $c1 = $window->Canvas(-width => 958 * $scale_faktor, -height => 150 * $scale_faktor, ) ->pack(); ... my $oval = $c1->createOval($x1, $y1, $x2, $y2, -fill => 'gray'); ...
1
2
3
4
5
6
7
$c = $mw->Scrolled("Canvas")->pack( );
$canvas = $c->Subwidget("canvas");
$canvas->CanvasBind("<Button-1>", [ \&print_xy, Ev('x'), Ev('y') ]);
sub print_xy {
my ($canv, $x, $y) = @_;
print "(x,y) = ", $canv->canvasx($x), ", ", $canv->canvasy($y), "\n";
}
my $w = $canvas->find("overlapping", $x, $y, $x, $y);