You have a serious misunderstanding of what is going on. Tk::ExecuteCommand is designed to do just that .... execute a command , which means sending a valid command to a shell to be run. What you want to do is just plainly run some perl code and have it's output in the Text widget.
For the question of killing a running command, make another button labeled 'Stop', and use Tk::ExecuteCommand's $exec->kill_command;
my $kill_button = $mw->Button( -text => 'Stop', -command=> sub{ $exec->kill_command; } )->pack();
As to your other problem of sending plain text messages to the Text Widget, instead of a command, you will need to figure out a way in your subroutine of determining if you have a valid command, or just an informational message. If it's an information message, you can write it directly into the ROText subwidget like the following:
#!/usr/bin/perl use Tk; use Tk::ExecuteCommand; my $mw = MainWindow->new; $ec = $mw->ExecuteCommand( -command => '', -entryWidth => 50, -height => 10, -label => '', -text => 'Execute', )->pack; $ec->configure( -command => 'dir' ); $ec->execute_command; $ec->bell; $ec->update; # read perldoc Tk::ExecuteCommand for the Advertised Widget section my $ROText = $ec->Subwidget('text'); print "$ROText\n"; $ROText->configure(-bg=>'white'); $ROText->insert('end', "\n\nHi, this is a message\n\n"); $ROText->see('end'); #execute some perl code and output it to the text widget &do_something; MainLoop; sub do_something{ # the Tk::ExecuteCommand kill button won't stop this for (1..5){ $ROText->insert('end', "$_\n"); $ROText->see('end'); } }
In reply to Re^3: How to perform a subroutine run in cpan Tk::ExecuteCommand module
by zentara
in thread How to perform a subroutine run in cpan Tk::ExecuteCommand module
by Janish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |