Newbie Tkinter problem

Simpa sinisa_pavlovic at yahoo.com
Thu Mar 29 13:55:08 CEST 2001


Hi.

When I start the following script twice, without leaving Python I got
TclError message (first time everything is OK). What am I doing wrong?

I am using Python 1.5.2 for Win32 with Mark Hammond's PyWin, but same
things happend on IDLE too.

Thanks in advance.
Simpa.




from Tkinter import *

class Wind:
    def __init__(self):
        self.root = Tk()
        self.root.title('Show image')
        
        self.c = Canvas(self.root,background = 'green')
        self.photo = PhotoImage(name = 'wedda',file="wedda.gif")
        self.c.create_image(0,0,image=self.photo,anchor=NW)
        self.c.pack(fill=BOTH,expand=1)

        self.root.mainloop()

MyWind = Wind()



>>> Traceback (innermost last):
  File "D:\PythonW32\Pythonwin\pywin\framework\scriptutils.py", line
237, in RunScript
    exec codeObject in __main__.__dict__
  File "D:\Private\PythonProba\Tkinter\Image.py", line 17, in ?
    MyWind = Wind()
  File "D:\Private\PythonProba\Tkinter\Image.py", line 11, in __init__
    self.photo = PhotoImage(name = 'wedda',file="wedda.gif")
  File "D:\Python\Lib\lib-tk\Tkinter.py", line 1874, in __init__
    apply(Image.__init__, (self, 'photo', name, cnf, master), kw)
  File "D:\Python\Lib\lib-tk\Tkinter.py", line 1839, in __init__
    self.tk.call(('image', 'create', imgtype, name,) + options)
TclError: can't invoke "image" command:  application has been
destroyed




More information about the Python-list mailing list