Gassho!
I could need a helping pair of eyes on this issue:
The general problem i'm wrestling is starting a
while(1) { do_something; sleep_awhile; } block in a Perl/Tk app, and still being able to break the loop through a GUI event such as a mouse click (that is: keeping the UI alive in parallel with the while(1)-loop).
________________________________________________________
I decided basing my solution on the small Tk:waitVariableX package from Mastering Perl/Tk (EMU:O'Reilly'02, pg392-393,also on
CPAN), -- in principle:
use Tk;
use lib ".";
use Tk::waitVariableX;
my $break;
sub start_it{
$break=0; while (!$break) {
my $result = foo($a1, $a2);
$detail->insert("1.0", $result);
$mw->waitVariableX(3000, \$break); # cf EMU-book
}
}
sub stop_it {
$break = 1; # set by mou-click
}
________________________________________________________
For some reason i keep getting :
Tk::Error: Failed to AUTOLOAD 'MainWindow::waitVariableX'
Carp::croak at C:/Perl/lib/Carp.pm line 269
Tk::Widget::__ANON__ at C:/Perl/site/lib/Tk/Widget.pm
________________________________________________________
TWO QUESTIONS:
(1) Specifically: Perl seems to able to locate the Tk::waitVariableX pm module (which i've placed in the "./Tk" dir), so why does Tk "Fail to AUTOLOAD" the module ...???
(2) And in general: is there a better way to solve the problem of
while(1){} and a responsive GUI in Perl/Tk ?
Best regards
-- allan
===========================================================
As the eternal tranquility of Truth reveals itself to us, this very place is the Land of Lotuses
-- Hakuin Ekaku Zenji
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.