in reply to Re^5: How to perform a subroutine run in cpan Tk::ExecuteCommand module
in thread How to perform a subroutine run in cpan Tk::ExecuteCommand module

Thanks Corion, By putting the whole execution line in $cmd, it works, but what I'm looking for is if the module can works on subroutine instead of a command. As there and something else extra I would like to put inside the subroutine before the one liner external command be executed. The Perl external script is part of the job inside my subroutine. Can this be done?

  • Comment on Re^6: How to perform a subroutine run in cpan Tk::ExecuteCommand module

Replies are listed 'Best First'.
Re^7: How to perform a subroutine run in cpan Tk::ExecuteCommand module
by Corion (Patriarch) on Jun 25, 2014 at 08:30 UTC

    Not directly with that module.

    I don't use Tk, so I don't really know alternatives to that, but I assume that you can look at the source code and adapt it so your callback gets run in a fileevent callback for the handle to the child process.

      Thank you Corion, I would be very much thankful if you could show a sample base on my code. I have been looking around for weeks to fix this matter, even there are sample codes available (actually I've looked into the filevent for the past days but not really get what is that about) but I could hardly apply them in depth base on my understanding on it. A real sample will help me a lot if you're not hesitate.

        What part of "I don't use Tk" leads you to asking me for sample code (in Tk)?

Re^7: How to perform a subroutine run in cpan Tk::ExecuteCommand module
by RonW (Parson) on Jun 25, 2014 at 16:34 UTC

    I could not find a widget that does what you ask, but

    Try [meatacpan://Tk::Text]

    I think something like:

    sub do_something { ... } sub do_something_else { ... } my $result = do_something; $tw->Insert($result); $result = do_something_else; $tw->Insert($result);

    should do what you want.

    Tk::Text::Insert inserts the supplied text at the insertion point. I think it advances the insertion point, so repeated calls will append to what was inserted by the previous call.

    This will accumulate text until Perl runs out of resources or you stop adding more text. There are methods to delete text from the widget.

    Alternately, you could maintain the text you want to display in your own variable, then update the widget as needed:

    $tw->Contents($textToDisplay);

      Thanks you RonW> but this is not something I looks for. I want a show state text widget and also cancel funtion to kill ongoing process.