#!/usr/bin/perl use warnings; use strict; use Tk qw/tkinit DoOneEvent exit DONT_WAIT ALL_EVENTS/; my $mw = tkinit; $mw->Button( -text => 'Test', -command => sub { print "Pushed\n" }, )->pack(); $mw->Button( -text => 'Quit', -command => sub { Tk::exit(0) }, )->pack(); my $I; while (1) { $mw->DoOneEvent( DONT_WAIT | ALL_EVENTS ); if ( ++$I > 10000 ) { #slows things down use 1 for max speed print '.'; $I = 0; } }