Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Tk::waitVariableX - AUTOLOAD failed

by jowe (Acolyte)
on Apr 09, 2013 at 14:48 UTC ( #1027757=perlquestion: print w/ replies, xml ) Need Help??
jowe has asked for the wisdom of the Perl Monks concerning the following question:

Hi PerlMonks,
the following code snippet demonstates my problem:
#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::waitVariableX; my $mw = MainWindow->new(); my $unchanged_var = ' '; while () { my $numtime = time (); my ($curr_sec, $curr_min, $curr_hour, $curr_mday, $curr_month, $cu +rr_year, $curr_wday, $curr_yday, $curr_isdst) = localtime ($numtime); + my $lab1 = $mw->Label (-text => 'time returned: ' . $curr_hour . ' +:' . $curr_min . ':' . $curr_sec) ->form(-left => '%5', -top => '%10'); $lab1->update; $mw->waitVariableX (5 * 1000, \$unchanged_var); # sleep 5 secon +ds } MainLoop;

The package (Tk::waitVariableX from cpan) installs ok but it seems like something is not set during the install process.
My environment: Windows 7, ActivePerl 5.16.3.1603 MSWin32, Tk: 804.030, Tk::waitVariableX: 1.0
The same behavior under Linux.
Could you please let me know what I am doing wrong.
Thanks for your help - jowe

Comment on Tk::waitVariableX - AUTOLOAD failed
Download Code
Replies are listed 'Best First'.
Re: Tk::waitVariableX - AUTOLOAD failed
by choroba (Canon) on Apr 09, 2013 at 15:03 UTC
    The documentation is very laconic, but it seems you should use
    $splash->waitVariableX
    where $splash is Tk::Splashscreen.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: Tk::waitVariableX - AUTOLOAD failed
by hdb (Prior) on Apr 09, 2013 at 15:08 UTC

    I do not know why, seems strange object interface, but the following seems to work (experimental Perl):

    waitVariableX ($mw, 5 * 1000, \$unchanged_var); # sleep 5 secon +ds
      Thanks very much. It solved the problem (dont know why).
      Thanks again - jowe

        The documentation and the code of the module are looking inconsistent. The documentation says:

        $splash->waitVariableX( [$millis, $destroy_splashscreen], \$v1, \$v2} +);

        while in the code

        sub waitVariableX { use Tie::Watch; my ($parent, $millis) = (shift, shift); # @_ has list of var refs

        the arguments have different names (and probably different meaning as well).

Re: Tk::waitVariableX - AUTOLOAD failed
by choroba (Canon) on Apr 09, 2013 at 15:36 UTC
    What are you trying to achieve? If you just want something to happen repeatedly, use Tk::after. The module you use is intended for splash screens only.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Intention is to implement a non-blocking wait (other Tk-events to be processed), which may be interrupted by a 'wait-timer' or by a variable changing its content - whatever occurs first. The repetition (while loop) is merely used to demonstrate the issue.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1027757]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2015-07-31 08:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls