Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tk - change image on event

Status
Not open for further replies.

PDexter

IS-IT--Management
Jun 14, 2003
7
US
Hi,

I'm a little new to Tk so hope this isn't a dumb question.

I've created a window using Tk and I'd like to change a gif image based on an event in my mainloop (change a green check to a red stop sign). I'm using a label widget right now but I could use a different one. This is easy for text using the message or label widget because of -textvariable option. Unfortunately there isn't an -imagevariable option.

Any ideas on a event driven image change?

Thanks.


 
You should be able to just make a simple callback for whatever the event is. In that (possibly anonymous) sub, do whatever work needs to be done to swap the images.

________________________________________
Andrew

I work for a gift card company!
 
Thanks for the reply,

What I'm struggling with is the event is not user driven and coming from a button or other "normal" event. What I'm trying to do is when a value in my mainloop exceeds a certain value, then I want to change the image displayed in the Label. Most references I've found all are similar to your response where the event is triggered by a user.

Thanks again for any ideas.
 
Try looking at the Tk::progressBar module and the update function as well. You should find what you are looking for there. The progress bar checks a variable and the update forces the info within the variable to update the widget.

Michael Libeson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top