f



Trouble executing a perl script after a MainLoop using TK

OK.  So I've got my script working like I want using the TK to build my lis=
t of selections.  Now, however, when I close the menu, it does not execute =
my last statement in my program to run the next script after MainLoop;  Try=
ing to run my $var =3D`crossref.pl`; in order to go to my next script.  Bef=
ore adding the menu, this worked.  Now it does not.  I'm posting the last 1=
1 lines so you can see what I'm trying to do.  Any help is appreciated.

my $button_frame =3D $mw->Frame()->pack(-side =3D> "bottom");
my $ok_button =3D $button_frame->Button(-text =3D> 'OK',
                                       -command =3D> \&check_sub)->pack(-si=
de =3D> "left");
my $exit_button =3D $button_frame->Button(-text =3D> 'Exit',
                                        -command =3D> sub{exit})->pack(-sid=
e =3D> "right");

sub check_sub {
  my $check_msg =3D "Check #1: $check1\nCheck #2: $check2\nCheck #3: $check=
3\nCheck #4: $check4\nCheck #5: $check5\nCheck #6: $check6\nCheck #7: $chec=
k7\nCheck #8: $check8\nCheck #9: $check9\nCheck #10: $check10\nCheck #11: $=
check11\nCheck #12: $check12\nCheck #13: $check13\nCheck #14: $check14\n,Ch=
eck #15: $check15\nCheck #16 $check16";
  $mw->messageBox(-message =3D> "Check Button Summary:\n$check_msg", -type =
=3D> "ok");
}

MainLoop;

my $var =3D`crossref.pl`; #Should run my crossref.pl but does not.
0
dragolarik76
6/10/2016 6:29:51 PM
comp.lang.perl.tk 4721 articles. 0 followers. pharrendorf (19) is leader. Post Follow

2 Replies
418 Views

Similar Articles

[PageSpeed] 9

On 6/10/2016 11:29, dragolarik76@gmail.com wrote:
> OK.  So I've got my script working like I want using the TK to build my list of selections.  Now, however, when I close the menu, it does not execute my last statement in my program to run the next script after MainLoop;  Trying to run my $var =`crossref.pl`; in order to go to my next script.  Before adding the menu, this worked.  Now it does not.  I'm posting the last 11 lines so you can see what I'm trying to do.  Any help is appreciated.
>
> my $button_frame = $mw->Frame()->pack(-side => "bottom");
> my $ok_button = $button_frame->Button(-text => 'OK',
>                                        -command => \&check_sub)->pack(-side => "left");
> my $exit_button = $button_frame->Button(-text => 'Exit',
>                                         -command => sub{exit})->pack(-side => "right");
>
> sub check_sub {
>   my $check_msg = "Check #1: $check1\nCheck #2: $check2\nCheck #3: $check3\nCheck #4: $check4\nCheck #5: $check5\nCheck #6: $check6\nCheck #7: $check7\nCheck #8: $check8\nCheck #9: $check9\nCheck #10: $check10\nCheck #11: $check11\nCheck #12: $check12\nCheck #13: $check13\nCheck #14: $check14\n,Check #15: $check15\nCheck #16 $check16";
>   $mw->messageBox(-message => "Check Button Summary:\n$check_msg", -type => "ok");
> }
>
> MainLoop;
>
> my $var =`crossref.pl`; #Should run my crossref.pl but does not.

What menu?  If you press OK, you display a popup.  If you press Exit, you exit the program.
MainLoop has no exit - it loops forever.

The only way to get to the stmt after MainLoop would be to call it from one of your
buttons (make it into a sub or some such) or put it in an exit handler or END {} block
if your going to it.

EG:
my $exit_button = $button_frame->Button(-text => 'Exit',
   -command => sub{ my_exit (); })->pack(-side => "right");
sub my_exit { my $var =`crossref.pl`; }
or
END { my $var =`crossref.pl`; }

PS: Make sure when giving a sample script that it's runnable so it can be tested.
0
Bill
6/11/2016 1:24:56 PM
see also www.perlmonks.org/?node_id=547320

Use $mw->destroy() instead of exit().


----Android NewsGroup Reader----
http://usenet.sinaapp.com/

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
0
ulix
9/11/2016 1:53:26 PM
Reply: