I notice a rather strange error with tkinter, and I wonder if this is due to the fact that python interacts with tcl, at least in Win32.
Here I have a super simple program that displays a gif image. It works great.
from Tkinter import *
canvas = Canvas(width=300, height=300, bg='white')
canvas.pack()
photo=PhotoImage(file=sys.argv[1])
canvas.create_image(0, 0, image=photo, anchor=NW)
print canvas
print photo
mainloop( )
Now I am modifying the program a bit to edit the canvas object inside the function. This time I just get a blank canvas.
from Tkinter import *
canvas = Canvas(width=300, height=300, bg='white')
canvas.pack()
def set_canvas(cv):
photo=PhotoImage(file=sys.argv[1])
cv.create_image(0, 0, image=photo, anchor=NW)
print cv
print photo
set_canvas(canvas)
mainloop( )
The only difference between the two is that in one canvas the object is passed to the function instead of being used directly. Both print statements return identical results. I am wondering if, at least, a breakdown in the object model is possible at the tcl / python level.
Any thoughts people?
Thanks, / YGA