(no subject)

moonlite56 at yahoo.com moonlite56 at yahoo.com
Fri Aug 17 03:02:25 CEST 2001


How do you predefine a function? I want to change an image in a 
canvas and update it, but it (of course) comes up the error that the 
canvas is "referenced before assignment." :) I know there's a way to 
predefine the function at the beginning of my program but actually 
define it later on, but I don't know how. Can someone else help?

Here's my program thus far:

---------------

from Tkinter import *
import Image,ImageTk

def changeimage():
        cKuti3.delete(myimage)
	iKuti3 = 
ImageTk.PhotoImage(Image.open("outfit/pinkvest.gif"))
	cKuti3 = cpic.create_image(0, 0, anchor = NW, image = iKuti3)

top = Tk()
top.title("Kuti")
top.geometry("200x100")

iKuti1 = ImageTk.PhotoImage(Image.open("body/lighttan.gif"))
iKuti2 = ImageTk.PhotoImage(Image.open("hair/brownbuns.gif"))
iKuti3 = ImageTk.PhotoImage(Image.open("outfit/whiteblouse.gif"))

cpic = Canvas(width = 40, height = 40)
cpic.grid(column = 0, row = 0, columnspan = 2)

cKuti1 = cpic.create_image(0, 0, anchor = NW, image = iKuti1)
cKuti2 = cpic.create_image(0, 0, anchor = NW, image = iKuti2)
cKuti3 = cpic.create_image(0, 0, anchor = NW, image = iKuti3)

changeimage()

top.mainloop()






More information about the Python-list mailing list