Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: How to perform a subroutine run in cpan Tk::ExecuteCommand module

by zentara (Archbishop)
on Jun 26, 2014 at 11:00 UTC ( [id://1091333]=note: print w/replies, xml ) Need Help??


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

is there a way to print plain font to the text widget in Tk::ExecuteCommand say if I don't want to set a couple of mini scripts for simple info message? ....
'Start running project 1...please wait' : No such file or directory

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'); } }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^4: How to perform a subroutine run in cpan Tk::ExecuteCommand module
by Janish (Sexton) on Jun 27, 2014 at 05:22 UTC

    Hi Zentara, I couldn't help to express my thankfulness to you, your explanation and sample codes did help me to clear my doubts and misunderstanding on all those that I found by googling, which bothering me since the past weeks. Now I'm much clearer on the usage and how to apply both the ROText and ExecuteCommand in my codes. Yeah.. the explanation with sample codes means a lot! ALso, not forget to thanks all those who take the trouble on replying to me- Corion and RonW. I'm so excited to implement that in my real code now! Thanks a bunch!

Re^4: How to perform a subroutine run in cpan Tk::ExecuteCommand module
by Janish (Sexton) on Jun 27, 2014 at 07:20 UTC

    Hi Zentara, I have one extra question regarding the text widget gui, is that possible to change the vertical scrollbar to the right hand side instead of current position on the left sided.

      You probably will have to dig into the "advertised widgets" of Tk::ExecuteCommand, find the scrolled frame, then issue a configure command to it. -scrollbars => 'osoe'

      This code change does it:

      # read perldoc Tk::ExecuteCommand for the Adverised Widget section my $ROText = $ec->Subwidget('text'); print "$ROText\n"; $ROText->configure(-scrollbars => 'osoe');

      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh
        Thanks Zentara, I changed to 'se' and it works as what I wanted. I read through the Tk::RoText manual but seems don't have the cmd "$ROText->configure(-scrollbars => 'osoe');" you posted, and I never know the configure command can be used for -scrollbar if you never tell. Thanks a lot!
        Hi Zentara, I tried up vote your answer, not sure if that works at your end. This is my first time voting on PerlMOnks, let me know if that doesn't works. Thank you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1091333]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-25 14:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found