joybee has asked for the wisdom of the Perl Monks concerning the following question:

I need a window to update the status of the running processes but my code doesn't work

#!/usr/bin/perl use Tk; my $cmd1 = "./test1.sh"; my $msg = "testing"; $main = MainWindow->new(); $main->geometry( '300x100' ); $main->Label( -textvariable => \$msg)->pack( -expand => 1); $main->Button( -text => "Run", -command => \&test_run) ->pack(-side => "left"); $main->Button( -text => "Quit", -command => sub { exit } ) ->pack(-side => "right"); MainLoop; sub test_run { my $pid = fork(); if (not defined $pid) { $msg = "resources not avilable.\n"; } else { print "I'm the parent\n"; $msg = "Run $cmd1\n"; print $msg; waitpid($pid, 0); my $ret = $? >> 8; $msg = "$cmd1 exit with return value $ret\n"; } #more forked child... }

The label widget didn't get updated.

Thanks!

Replies are listed 'Best First'.
Re: help needed with simple tk interface
by Anonymous Monk on Nov 10, 2011 at 22:31 UTC

      linux

      thanks

Re: help needed with simple tk interface
by Anonymous Monk on Nov 11, 2011 at 01:51 UTC

    Hi,

    After making the change try $main->update();

    J.C.

Re: help needed with simple tk interface
by keszler (Priest) on Nov 11, 2011 at 01:52 UTC

    Try $main->update; after changing $msg.

Re: help needed with simple tk interface
by joybee (Initiate) on Nov 11, 2011 at 14:36 UTC

    Thanks everyone for your help

    It works!