Newbie: Non-interactive status displays - HOWTO?

C

Chris

I'm a perl Tk newbie trying to create a pgm to display the status of
several servers by a green/red indicator light. After going over some
howto's & examples, I'm still stumped.

All of the examples I can find are geared towards dealing with some user
interaction (clicking buttons, typing text, etc.), but I'm looking for a
non-interactive update of status lights, say when a server goes down,
stops listening on a port, etc.

Basically I'd like to know how to update a widget color based on results
from a monitoring subroutine - ie how to pass info back into the Tk
window. I tried setting a text widget to a global variable that gets
manipulated in a routine forked prior to MainLoop, but no luck.

Sooooo....can anybody provide guidance as how to pass values back into a
Tk window? Examples greatly appreciated..

TIA
 
J

Joost Diepenmaat

Chris said:
I'm a perl Tk newbie trying to create a pgm to display the status of
several servers by a green/red indicator light. After going over some
howto's & examples, I'm still stumped.

All of the examples I can find are geared towards dealing with some
user interaction (clicking buttons, typing text, etc.), but I'm
looking for a non-interactive update of status lights, say when a
server goes down, stops listening on a port, etc.

Basically I'd like to know how to update a widget color based on
results from a monitoring subroutine - ie how to pass info back into
the Tk window. I tried setting a text widget to a global variable that
gets manipulated in a routine forked prior to MainLoop, but no luck.

Tk is event based. That means that you're just executing code whenever
some event happens. The event can be a user action but it can also be
activity on a socket or a timeout or whatever.

You may want to look at the Tk::after manpage.

Joost.
 
C

Chris

Joost said:
Tk is event based. That means that you're just executing code whenever
some event happens. The event can be a user action but it can also be
activity on a socket or a timeout or whatever.

You may want to look at the Tk::after manpage.

Joost.
Thx...I'll check that out
 
M

MK

I'm a perl Tk newbie trying to create a pgm to display the status of
several servers by a green/red indicator light. After going over some
howto's & examples, I'm still stumped.

All of the examples I can find are geared towards dealing with some user
interaction (clicking buttons, typing text, etc.), but I'm looking for a
non-interactive update of status lights, say when a server goes down,
stops listening on a port, etc.

Basically I'd like to know how to update a widget color based on results
from a monitoring subroutine - ie how to pass info back into the Tk
window. I tried setting a text widget to a global variable that gets
manipulated in a routine forked prior to MainLoop, but no luck.

Sooooo....can anybody provide guidance as how to pass values back into a
Tk window? Examples greatly appreciated..

TIA

It may be easier to destroy and recreate a widget, eg. in a different
color, than to change the color of an existing widget, and it looks
exactly the same.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top