Home > Archive > PerlTk > December 2005 > Looking for a data driven widget
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Looking for a data driven widget
|
|
|
| Admittedly, I'm new to Tk (but not Perl), so this may be a newbie
question.
All of the widgets I've found have one thing in common: they require
user input to run the code.
I have an application that will read data from a file (or possibly a
database) and needs to update that data to the display automatically.
My preference would be to have it execute the code upon receiving
something on a socket, but my options are open.
Thanks,
Jay
| |
| Petr Vileta 2005-12-10, 7:12 pm |
| Jay wrote:
> Admittedly, I'm new to Tk (but not Perl), so this may be a newbie
> question.
>
> All of the widgets I've found have one thing in common: they require
> user input to run the code.
>
> I have an application that will read data from a file (or possibly a
> database) and needs to update that data to the display automatically.
> My preference would be to have it execute the code upon receiving
> something on a socket, but my options are open.
>
This is very simple ;-)
use Tk;
use Tk::Label;
use strict;
our $line='';
our $counter=0;
our $mw = MainWindow->new();
our $label =
$mw->Label(-width=>100, -height=>5, -textvariable=>\$line, -relief=>'sunken')
->pack(-anchor=>'nw', -side=>'top');
$mw->repeat(1000, sub {&do_something;});
MainLoop;
sub do_something
{
my $file='c:/some_file.txt';
open IN,"<$file";
my $oneline;
while($oneline = <IN> )
{
$counter++;
$line = "Line: $counter\n$oneline";
$label->update;
sleep 2;
}
close IN;
$line = "That's all, folks";
$label->update;
}
--
Petr Vileta, Czech republic
(My server reject all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
| |
|
| Simple enough and it doesn't seem to use much CPU. Thanks.
One thing though, I couldn't find docs for the "repeat" widget in my
installed docs, or on CPAN. Where should I look?
| |
| Marc Dashevsky 2005-12-10, 10:09 pm |
| Jay <jaykoni@yahoo.com> writes in article %:
> Simple enough and it doesn't seem to use much CPU. Thanks.
>
> One thing though, I couldn't find docs for the "repeat" widget in my
> installed docs, or on CPAN. Where should I look?
It's a method, not a widget, and it is documented in the Tk::after pod.
--
Go to http://MarcDashevsky.com to send me e-mail.
| |
| Petr Vileta 2005-12-11, 7:13 pm |
| Jay wrote:
> Simple enough and it doesn't seem to use much CPU. Thanks.
>
> One thing though, I couldn't find docs for the "repeat" widget in my
> installed docs, or on CPAN. Where should I look?
Repeat is documented in Tk::after but on CPAN is nothing about Tk::after :-(
I have ActivePerl with better documentation :-) Look here
http://aspn.activestate.com/ASPN/do...b/Tk/after.html
--
Petr Vileta, Czech republic
(My server reject all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
| |
| Petr Vileta 2005-12-11, 7:13 pm |
| Marc Dashevsky wrote:
> Jay <jaykoni@yahoo.com> writes in article %:
>
> It's a method, not a widget, and it is documented in the Tk::after
> pod.
But on CPAN is not the Tk::after pod document :-(
--
Petr Vileta, Czech republic
(My server reject all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
| |
| Marc Dashevsky 2005-12-11, 10:11 pm |
| Petr Vileta <stoupa@practisoft.cz> writes in article %:
> Marc Dashevsky wrote:
> But on CPAN is not the Tk::after pod document :-(
It's in the core Tk documentation.
--
Go to http://MarcDashevsky.com to send me e-mail.
| |
|
|
| Petr Vileta 2005-12-12, 8:16 am |
| "Rob Seegel" <RobSeegel@comcast.net> píse v diskusním príspevku
news:LKadnaLb1d9CngDenZ2dnUVZ_tudnZ2d@co
mcast.com...
> Petr Vileta wrote:
>
> It kind of depends where you look ;-)
>
> http://search.cpan.org/~ni-s/Tk-804.027/pod/after.pod
??? :-) I was looking to module section and Tk::after is on documentation
section.
Maybe is too hard to add the link into module section too :-)
--
Petr Vileta, Czech republic
(My server reject all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
|
|
|
|
|