[Tutor] Tkinter PhotoImage widget question

Max Sorenson sk8ter9728@msn.com
Thu, 23 May 2002 09:50:13 -0500


My name is Max Sorenson, I am student in Mr.Wilson's computer programing 
class at Henry Sibley High School. I am in the process of writing a program 
which uses METAR to get current weather conditions, and Tkinter to display 
the weather. I am trying to display an image for the wind direction using 
the PhotoImage widget, but I am having trouble gettting that code right.

Here is the error that I am getting

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\PYTHON22\lib\lib-tk\Tkinter.py", line 1292, in __call__
    return apply(self.func, args)
  File "H:\metarGUI2.py", line 81, in windDirection
    self.lprintPicture = Label(self.picF, image = self.picture)
  File "C:\PYTHON22\lib\lib-tk\Tkinter.py", line 2261, in __init__
    Widget.__init__(self, master, 'label', cnf, kw)
  File "C:\PYTHON22\lib\lib-tk\Tkinter.py", line 1756, in __init__
    self.tk.call(
TclError: image "pyimage2" doesn't exist

Every time that the program is ran, the "pyimage2" increases. For example, 
the next time it is run, the error will be "pyimage3"

Here is some of the code that appears to be causing the problem:

self.outputWind = Tk()
self.outputWind.title("Wind Dir.")
self.picF = Frame(self.outputWind)
self.picture = PhotoImage(file = "north2.gif")
self.lprintPicture = Label(self.picF, image = self.picture)
self.lprintPicture.pack()
self.picF.pack()
self.outputWind.pack()

Does anybody have any ideas of what may be causing the error, or if there is 
another way to display a simple image in a Tkinter window.
                                           Thanks,
                                                Max


_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com