Tk::Stderr - capture standard error output, display in separate window
use Tk::Stderr; $mw = MainWindow->new->InitStderr; print STDERR 'stuff'; ## goes to standard error window warn 'eek!'; ## likewise
This module captures that standard error of a program and redirects it to a read only text widget, which doesn't appear until necessary. When it does appear, the user can close it; it'll appear again when there is more output.
These are actually added to the MainWindow class.
The first time this method called, it does the following things:
Creates a MainWindow holding a read-only scrollable text widget, and withdraws this window until it's actually needed.
Ties STDERR to a special handle that adds the output to this text widget.
Installs a $SIG{__WARN__} handler that redirects the output from warn to this window as well (by printing it to STDERR).
$SIG{__WARN__}
On the remaining calls, it:
Increments a reference count of "other" MainWindows.
Installs an OnDestroy handler that decrements this reference count, so that it can detect when it's the only MainWindow left and destroy itself.
Returns a reference to the main window holding the text. You can use this to configure the window itself or the widgets it contains. The only advertised subwidget is 'text', which is the scrolled read-only text widget.
Enables or disables the redirection of standard error to the text window. Set $boolean to true to enable redirection, false to disable it. Returns the previous value of the enabled flag.
If InitStderr has never been called, this routine will call it if $boolean is true.
Kevin Michael Vail <kevin@vaildc.net>
To install Tk::Stderr, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tk::Stderr
CPAN shell
perl -MCPAN -e shell install Tk::Stderr
For more information on module installation, please visit the detailed CPAN module installation guide.