#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Dialog; my $mw = MainWindow->new(-title => 'Demonstration von Tk::Dialog'); $mw->Button( -text => 'Dialog öffnen', -command => \&button_start, )->pack( -side => 'top', -fill => 'none', -expand => 1, -ipadx => 10, -ipady => 5, ); $mw->geometry('300x100'); MainLoop(); sub button_start { my $dialog = $mw->Dialog( -text => "Text, der im Dialog angezeigt wird.\n". "mit \\n können Umbrüche erzeugt werden.", -bitmap => 'info', -title => 'unser schöner neuer Dialog', -default_button => 'OK', -buttons => [ 'OK', 'Toll', 'Find ich klasse :-)', 'Nun reicht\'s' ], -font => '{Times New Roman} 12 {normal}', ); my $answer = $dialog->Show(-global); print "Antwort war: $answer\n"; exit(0) if $answer eq 'Nun reicht\'s'; }