#!/usr/bin/perl -w
######################################################################
# dialog.pl
######################################################################
# Perl Power! - Michael Schilli 1998
######################################################################

use Tk;
use Tk::Dialog;

$top = MainWindow->new();

$top->Button(-text => "Start dialog", 
             -command => sub { dialog($top); })->pack();
$top->Button(-text => "Exit", -command => sub { exit 0 } )->pack();

MainLoop;

sub dialog {
    my $top = shift;

    my $okButton     = 'OK';
    my $cancelButton = 'Cancel';
    my $helpButton   = 'Help';
    
    my $dialog = $top->Dialog(
                     -title => 'Title',
                     -text  => 'Text of the error message, and so forth',
                     -bitmap => 'info',
                     -default_button => $okButton,
                     -buttons => 
                         [$okButton, $cancelButton, $helpButton]);

    if(($returnButton=$dialog->Show('-global')) eq $okButton) {
        print "OK\n";
    } elsif ($returnButton eq $cancelButton) {
        print "Cancel\n";
    } elsif ($returnButton eq $helpButton) {
        print "Help\n";
    }
}

