[Tutor] <<NEWBIE>> Soooooo CLOSE!!! :-)

Chris McCormick livelikemad@yahoo.com
Mon, 26 Feb 2001 13:48:28 -0800 (PST)


Ok peeps,
  As per my message earlier today, I am trying to get
an image to display in a Tk window.  Here is my source
code:

from Tkinter import *

class App:
  def __init__(self, master):
    frame = Frame(master)
    frame.pack()
    self.canvas = Canvas(frame, bg="red",width=601,
height=601)
    self.canvas.pack()
		
    photo = PhotoImage(file="bg1.gif")
    self.item = self.canvas.create_image(10, 10,
anchor=NW, image=photo)

root = Tk()
app = App(root)
root.mainloop()

I don't get any error messages - what I do get is a
big window with the red background.  My guess is that
after I create the image, I have to do something to
make it visible?  I tried adding a line like this:

self.item.pack()

but it gives me the error:

AttributeError: 'int' object has no attribute 'pack'

I guess that means that item is just the ID of the
image rather than the image itself?

*sigh*  I'm so close I can taste it. If anyone can
help me, I'd be much obliged.

- Chris

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/