use Tk; my $mw = MainWindow->new; my $canvas = $mw->Canvas-> pack(-expand => 1, -fill => 'both'); $canvas->Tk::bind('', sub { my $c = shift; print $c->width . " x " . $c->height . "\n"; }); MainLoop;