I am using Perl/Tk to create a GUI. The problem I need help on deals with running a separate perl script. So, I have the main GUI that is quite large. I want to run a separate script to do a lot of text analysis/manipulation. So, when I call the separate perl script from my GUI, I want to display some status messages of what its currently working on. I have created a test example to demonstrate what I am currently doing. The first is the main program and the second is the separate Perl script
MAIN:
#!/usr/bin/perl -w
# perlCall.pl
use Tk;
use TK::ROText;
# create the Main Windoow
my $mw = MainWindow->new;
$resultsBox = $mw->Scrolled('Text', -relief => 'sunken',
-width => 100,
-height => 32,
-background => 'gray90',
-scrollbars => 'ose',
-selectbackground => 'gray60',)->p
+ack(-fill => 'both', -expand => 1);
$mw->Button(-text => 'Run Script', -command => \&CallScript)->pack(-fi
+ll => 'both', -expand => 1);
sub CallScript {
@myarray = `perl C:\\IBM\\test_code\\otherScript.pl`;
$resultsBox->insert('end', "@myarray");
}
MainLoop;
SEPARATE: (otherScript.pl)
#!/usr/bin/perl -w
# otherScript.pl
for ($i = 0; $i < 10; $i++)
{
print "This is a test at iteration number: $i\n";
}
for ($i = 0; $i < 10; $i++)
{
sleep (1);
print "Testing $i, \n";
}
As shown in the example, it waits until the full separate script is finished before it displays any of the text. Basically, I want the GUI to act a command prompt that can be updated as the script goes along or at least have text updates. Such as when the first for loop finishes, insert that into the text box. On a less-important question, how do I insert the text without the space in the beginning of each line?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.