Changing files without making new images?

moonlite56 at yahoo.com moonlite56 at yahoo.com
Thu Aug 16 19:03:01 EDT 2001


Is it possible to change the image file of an image object in 
Tkinter without making new image objects? I'd like to do this 
because the program I'm writing uses a whole lot of images, and I 
don't want to make image objects for each one. :)

from Tkinter import *
import Image,ImageTk
top = Tk()
top.title("Kuti")
top.geometry("200x100")
iKuti = ImageTk.PhotoImage(Image.open("body/lighttan.gif"))
iKuti2 = ImageTk.PhotoImage(Image.open("hair/brownbuns.gif"))
iKuti3 = ImageTk.PhotoImage(Image.open("outfit/whiteblouse.gif"))
top.mainloop()

Also, this program uses images in a directory. Is there a way to 
move through each image without renaming them to 1.png, 2.png, 
3.png...? That would allow me to add as many images as I want, and 
pushing a button will display the next image. Any ideas?






More information about the Python-list mailing list