#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = new MainWindow; my $current_size = $mw->reqwidth . "x" . $mw->reqheight; my $old_current_size = $current_size; my $canvas = $mw->Canvas(-width => 300, -height => 300, -bg => 'black', )->pack(); $mw->bind( '', sub{ &OnResize }); my $leave = 0; $mw->bind( '',sub { $leave = 1; } ); $mw->bind( '',sub { $leave = 0; &OnResize; } ); $mw->bind( '<3>',sub { print "1\n"; my $width = $mw->width - 10; my $height = $mw->height - 10;; $canvas->configure(-width=> $width, -height => $height); $mw->update; } ); MainLoop; sub OnResize { my $current_size = $mw->width . "x" . $mw->height; if( $leave == 1) {return } if($old_current_size eq $current_size){return} ## Resize has occurred do something: printf( "Resize happened - old size: %s, new size: %s\n", $old_current_size, $current_size ); ## set the old size to the new size $old_current_size = $current_size; }