in reply to Re: Tk::ExecuteCommand - GUI not responding by executing longer running script
in thread Tk::ExecuteCommand - GUI not responding by executing longer running script
... is it actually possible to solve my problem so easily - just with changing this module (replace somehow the fileevent, which could be the problem)?sub _read_stdout { # Called when input is available for the output window. Also chec +ks # to see if the user has clicked Cancel. my($self) = @_; if ($self->{-finish}) { $self->kill_command; } else { my $h = $self->{-handle}; if ( sysread $h, $_, 4096 ) { my $t = $self->Subwidget('text'); $t->insert('end', $_); $t->yview('end'); } else { $self->{-finish} = 1; } } } # end _read_stdout sub execute_command { # Execute the command and capture stdout/stderr. my($self) = @_; my $h = IO::Handle->new; die "IO::Handle->new failed." unless defined $h; $self->{-handle} = $h; $self->{-pid} = open $h, $self->{-command} . ' 2>&1 |'; if (not defined $self->{-pid}) { $self->Subwidget('text')->insert('end', "'" . $self->{-command} . "' : $!\n"); $self->kill_command; return; } $h->autoflush(1); $self->fileevent($h, 'readable' => [\&_read_stdout, $self]); my $doit = $self->Subwidget('doit'); $doit->configure( -text => 'Cancel', -relief => 'raised', -state => 'normal', -command => [\&kill_command, $self], ); my $doit_bg = ($doit->configure(-background))[3]; $self->_flash_doit(-background => $doit_bg, qw/cyan 500/); $self->waitVariable(\$self->{-finish}); } # end execute_command
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Tk::ExecuteCommand - GUI not responding by executing longer running script
by zentara (Cardinal) on Feb 05, 2008 at 21:12 UTC | |
by dzon (Novice) on Feb 07, 2008 at 10:23 UTC | |
by dzon (Novice) on Feb 13, 2008 at 14:22 UTC | |
by TGI (Parson) on Feb 13, 2008 at 20:10 UTC |