#!/usr/bin/perl use warnings; use strict; use Tk; require Tk::Dialog; my $result = 'Starting'; my $we_top = new MainWindow; my $message = "Cannot see if Segmentation fault\n"; my $count = 1; $we_top->Label ( -text => $message)->pack(); my $count_lab = $we_top->Label ( -textvariable => \$count)->pack(); my $okay_button = $we_top->Button( -text => 'Get Response', -command => [\&get_response, $result] )->pack(); my $exit_button = $we_top->Button( -text => 'Exit', -command => sub {exit} )->pack(); $we_top->MainLoop; ########################################## sub analyze_response { my $answer = shift; if( $answer eq 'Yes' ){ $result = "Continue at count $count ?"; } if( $answer eq 'No' ){ $result = "Rerun ?"; } if( $answer eq 'Cancel' ){ $result = "Cancelled ?"; } } ########################################### sub get_response { my $answer = do_dialog(); $count++; print "$answer\n"; &analyze_response( $answer ); } ####################################### sub do_dialog { my $dlg = $we_top->Dialog( -title=>"Here is a question for you.", -buttons => ["Cancel", "No", "Yes"], -default_button => "No", -text => $result, -font => "Helvetica" ); my $return = $dlg->Show(); return $return; } __END__