#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    2
    Rep Power
    0

    Need some help with Tkinter and error


    I grabbed this snippet of code off a website somewhere, cause I wanted to see how it worked.

    import Tkinter
    from Tkconstants import *

    def window(tk):
    global photo
    frame=Tkinter.Frame(tk)
    frame.pack()
    canvas=Tkinter.Canvas(frame,width=400,height=500)
    canvas.pack()
    photo=Tkinter.PhotoImage(file="c:\\temp1\\sn.gif")
    canvas.create_rectangle(10,20,30,40, fill="red")
    canvas.create_image(200, 250, image=photo)
    button=Tkinter.Button(frame, text="EXIT", command=tk.destroy)
    button.pack()

    root = Tkinter.Tk()
    window(root)
    root.mainloop()

    However, I'm getting the following error:

    TclError: image "pyimage5" doesn't exist

    I checked the forum, and couldn't see anything that would help. I'm running XP, if that would make a diff.

    Thanks for any help
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    394
    Rep Power
    51
    Hi!

    Did you also grab the image "sn.gif" and save it at "c:\\temp1\\sn.gif"?

    Regards,
    mawe
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    2
    Rep Power
    0
    Total dunderhead move. I completely forgot to install PIL, once I did, everything worked.

    Thanks though

    Jeez, I'm so embarassed

IMN logo majestic logo threadwatch logo seochat tools logo