So here is an outline of the way to do it ( others may have similar solutions). Basically you need to only create the mainwindow once, then use Dialogs to ask your questions. This way the mainloop will run solid until you hit the exit button.
I only put rudimentary logic into the analyze_results sub, but your should be able to see the way to analyze your results, and ask new questions.
#!/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__
In reply to Re: "Segmentation fault after destroying window"
by zentara
in thread "Segmentation fault after destroying window"
by mnooning
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |