
Tk::ExecuteCommand - execute a command asynchronously (non-blocking).

$exec = $parent->ExecuteCommand;

Tk::ExecuteCommand runs a command yet still allows Tk events to flow. All command output and errors are displayed in a window.
This ExecuteCommand mega widget is composed of an LabEntry widget for command entry, a "Do It" Button that initiates command execution, and a ROText widget that collects command execution output.
While the command is executing, the "Do It" Button changes to a "Cancel" Button that can prematurely kill the executing command. The kill_command method does the same thing programmatically.

The command to execute asynchronously.
Character width of command Entry widget.
Character height of the ROText widget.
Label text for command Entry widget.
Label text for "Do It!" Button.
Character width of the ROText widget.

Initiates command execution.
Returns a 2 element array of $? and $! from last command execution.
Terminates the command. This subroutine is called automatically via an OnDestroy handler when the ExecuteCommand widget goes away.
packForgets all but the minimal ROText widget. Currently, this action cannot be rescinded.

Component subwidgets can be accessed via the Subwidget method. Valid subwidget names are listed below.
Refers to the command LabEntry widget.
Refers to the command execution Button.
Refers to the spacer Frame separating the Entry and ROText widgets.
Refers to the Label across the top of the ROText widget.
Refers to the ROText widget that collects command execution output.

$ec = $mw->ExecuteCommand(
-command => '',
-entryWidth => 50,
-height => 10,
-label => '',
-text => 'Execute',
)->pack;
$ec->configure(-command => 'mtx -f /dev/sch0 load 1 0');
$ec->execute_command;
$ec->bell;
$ec->update;

exec, command, fork, asynchronous, non-blocking, widget

Copyright (C) 1999 - 2003 Stephen O. Lidie. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.