Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Real simple Tk label

by kb2yht (Acolyte)
on Mar 12, 2001 at 12:05 UTC ( #63772=perlquestion: print w/replies, xml ) Need Help??

kb2yht has asked for the wisdom of the Perl Monks concerning the following question:

Hi perl Monks.

I'me trying to make a, err... well ... its a Tk window with a Label in it,
thats it, and the label just has a number in it.
The Number is stored in $foo. and is updated by the program every 5sec or so.
How do I get the number to update in the Tk window ??
the window is just
$mw = MainWindow->new;
$tes = $mw->Label(-text=> "$foo");
$tes->pack;
MainLoop;

I know it must be trivial to do ,
I just cant do it :-( .
Many thnaks
Bill.

Replies are listed 'Best First'.
Re: Real simple Tk label
by danger (Priest) on Mar 12, 2001 at 12:25 UTC

    I think you are looking for the -textvariable option, and give it a reference to a scalar:

    #!/usr/bin/perl -w use strict; use Tk; my $foo = 500; my $mw = MainWindow->new; my $tes = $mw->Label(-textvariable => \$foo); $tes->pack; $mw->repeat(3000,sub{$foo++}); MainLoop(); __END__

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2023-12-09 12:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (38 votes). Check out past polls.

    Notices?