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!
In reply to help needed with simple tk interface by joybee
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |