[Tkinter-discuss] Continued: force the GUI to switch image instead of relying on the <button-1> event

chris chia hyperila at hotmail.com
Fri Aug 13 12:19:26 CEST 2010

I wish to do a multi threading program such that user can still use the console to control this GUI.
Can I ask u how can i write a command to force the GUI to switch image instead of relying on the <button-1> event.

thanks to Firat,

his code is as the following: 
import sys
import Tkinter as tk
from PIL import Image, ImageTk

class ImageViewer(object):
    def __init__(self):
        self.imagelist = [image1, image2]
        self.ind = 0

    def create_widgets(self):
        self.label = tk.Label(image = self.imagelist[0])
        self.label.bind("<Button-1>", self.change_image)

    def change_image(self, event):
        self.ind += 1
            self.label["image"] = self.imagelist[self.ind]
        except IndexError:

root = tk.Tk()

image1 = ImageTk.PhotoImage(file = "test1.jpg")
image2 = ImageTk.PhotoImage(file = "test2.jpg")

w = image1.width()
h = image1.height()

x = 0
y = 0

root.geometry("%dx%d+%d+%d" % (w, h, x, y))
app = ImageViewer()


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20100813/cc42518b/attachment.html>

More information about the Tkinter-discuss mailing list