NAME
Tk::ExecuteCommand - execute a command asynchronously (non-blocking).
SYNOPSIS
$exec = $parent->ExecuteCommand;
DESCRIPTION
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.
OPTIONS
- -command
-
The command to execute asynchronously.
- -entryWidth
-
Character width of command Entry widget.
- -height
-
Character height of the ROText widget.
- -label
-
Label text for command Entry widget.
- -text
-
Label text for "Do It!" Button.
- -width
-
Character width of the ROText widget.
METHODS
- $exec->execute_command;
-
Initiates command execution.
- $exec->get_status;
-
Returns a 2 element array of $? and $! from last command execution.
- $exec->kill_command;
-
Terminates the command. This subroutine is called automatically via an OnDestroy handler when the ExecuteCommand widget goes away.
- $exec->terse_gui;
-
packForgets all but the minimal ROText widget. Currently, this action cannot be rescinded.
ADVERISED SUBWIDGETS
Component subwidgets can be accessed via the Subwidget method. Valid subwidget names are listed below.
- Name: command, Class: LabEntry
-
Refers to the command LabEntry widget.
- Name: doit, Class: Button
-
Refers to the command execution Button.
- Name: spacer, Class: Frame
-
Refers to the spacer Frame separating the Entry and ROText widgets.
- Name: label, Class: Label
-
Refers to the Label across the top of the ROText widget.
- Name: text, Class: ROText
-
Refers to the ROText widget that collects command execution output.
EXAMPLE
$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;
KEYWORDS
exec, command, fork, asynchronous, non-blocking, widget
COPYRIGHT
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.