Tkinter - image not found.

Grzegorz Dostatni grzegorz at ugrad.cs.ualberta.ca
Wed Jun 21 12:49:41 EDT 2000


Hello. 
I'm trying to put an image on a frame.  What I am doing is something like
this:

label=Tkinter.Label(container)	
pic = Tkinter.PhotoImage(file="SAR.gif")
label["image"]=pic
label.pack()

This is essentially it.  Problem is, this code works when tested, but will
not work from my program.
Somehow the pic does not hold a valid reference after that second line.
(I think it loads a picture, but where does it go?)

Here's the trace:
Traceback (innermost last):
  File "main.py", line 18, in ?
    main()
  File "main.py", line 15, in main
    interface.Interface(cnx)
  File "interface.py", line 57, in __init__
    self.root=self.CreateRoot(cnx,lst[0])
  File "interface.py", line 166, in CreateRoot
    self.SetUpTopLevel(cnx, dict, frame)
  File "interface.py", line 227, in SetUpTopLevel
    self.TestPhoto(cnx,dict,frame)
  File "interface.py", line 255, in TestPhoto
    label["image"]=pic
  File "/usr/local/lib/python1.5/lib-tk/Tkinter.py", line 630, in
__setitem__
    self.configure({key: value})
  File "/usr/local/lib/python1.5/lib-tk/Tkinter.py", line 623, in
configure
    self.tk.call((self._w, 'configure')
TclError: image "1065616" doesn't exist


I'm out of ideas.  Any help will be greatly appreciated..
Greg

container is the top level widget.

########################################################################
SCSI is not magic. There are fundamental technical reasons why it
  is necessary to sacrifice a young goat to your SCSI chain now and
  then.                                                       -- Anon. 

"If you want to know what God thinks about money, just look at the people
He gives it to." 
-- Old Irish Saying 

Time is the best teacher. Unfortunately, it kills all its students. 




More information about the Python-list mailing list