#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new(); $mw->protocol('WM_DELETE_WINDOW', \&ExitApplication); MainLoop; 1; sub ExitApplication { # Prepare dialog yes|no my $dialog = $mw->Dialog(-text => 'Wollen Sie wirklich beenden?', -bitmap => 'question', -title => 'Quit?', -default_button => 'Yes', -buttons => [qw/Yes No/], ); # Dialog my $answer = $dialog->Show(); # and display dialog if ($answer =~ /y/i){ print "\nEs wurde ja ausgewaehlt.\n"; exit(0); } # if else { print "\nEs wurde nein ausgewaehlt.\n"; } # else } # ExitApplication