#!/usr/bin/perl use strict; use warnings; use Carp qw/croak/; use Data::Dumper qw/Dumper/; use Tk; use Tk::Canvas; my $mw = Tk::tkinit(); my $c = $mw->Canvas(-width => 800, -height => 640,)->pack(-fill => 'both', -expand => 1); my $x = 0; my $y = 0; my $pos_label_x = $mw->Label(-textvariable => \$x)->pack(); my $pos_label_y = $mw->Label(-textvariable => \$y)->pack(); $c->Tk::bind('',[\&print_coords,Ev('x'),Ev('y')]); my $text_id = $c->createText(50, 50, -text => "variabler Text"); my $oval_id = $c->createOval(10, 10, 60, 40, -fill => 'white'); $mw->MainLoop(); sub print_coords { shift; $x = $_[0]; $y = $_[1]; } # /print_coords