sub center { my $win = shift; $win->withdraw; # Hide the window while we move it about $win->update; # Make sure width and height are current # Center window my $xpos = int(($win->screenwidth - $win->width ) / 2); my $ypos = int(($win->screenheight - $win->height) / 2); $win->geometry("+$xpos+$ypos"); $win->deiconify; # Show the window again }