use warnings; use strict; use Tk; my $mw = tkinit(); my $button = $mw->Button( -text => 'Button', -command => \&buttonPress )->pack(); $mw->MainLoop(); sub buttonPress{ print 'RootX:' . $button->rootx . "\n"; print 'RootY:' . $button->rooty . "\n"; my ( $width, $height, $deltax, $deltay ) = split /[+x]/, $button->geometry; print join "\n", "Height: $height", "Width: $width", "Delta X (from root): $deltax", "Delta Y (from root): $deltay"; }