Tkinter Images

Fredrik Lundh fredrik at pythonware.com
Wed Nov 23 14:54:57 EST 2005


"Tuvas" wrote:

> Update: I can put the image in, but it spits out errors, adding this to
> it:
>
> canvas.insert(pic)

the "insert" method is used to insert text into canvas text items; the
syntax is

    canvas.insert(tag, position, text)

I'm not sure what you're saying here; did you get errors when you did
this, or did this eliminate whatever errors you got when you created the
image?

> BTW, I noted that my code was written incorectly The function should be
> as follows:
>
> def change_pic(path):
>  global pic
>  image=Image()               #I'm using PIL to use the images, but I

is that a PIL Image object or a Tkinter Image object?  if you're using PIL,
you need to use the ImageTk module to convert the PIL image to a format
suitable for Tkinter.

if you're using Tkinter images, you really want the PhotoImage class.  Image
is just a base class; it doesn't really provide any behaviour.

> don't think it's depended... This code's not the important one...
>  pic=canvas.create_image(1,1,image=image, anchor=NW)
>
> Note, add the first line above and it works.
>
> The question, how do I get it to work without the error messages?

can you perhaps post the error message?

</F> 






More information about the Python-list mailing list