Tkinter-create_image-Problem
Eric Brunel
eric.brunel at pragmadev.com
Thu Jan 10 04:56:56 EST 2002
I had to hack your code a bit to make it work (is this really your actual
code???), but I found the problem: just replace
self.img = PhotoImage('image.gif')
with:
self.img = PhotoImage(file='image.gif')
and everything should work...
BTW, to make this code work, I had to change the super-class for App from
Frame to Tk, delete the line "Pack.config(self)" and replace the line
"self.C.pack(TOP)" with "self.C.pack(side=TOP)". But maybe it's just
because I'm using Python 2.1 (has the Tkinter changed so much between 2.1
and 2.2???)
HTH
- eb -
A.A wrote:
> Thanks for the reply, Eric.
>
> The code is:
>
> from Tkinter import *
>
> class App(Frame):
> def __init__(self, master=None):
> Frame.__init__(self, master)
> Pack.config(self)
> self.createW()
> self.img = PhotoImage('image.gif')
> self.C.create_image(20, 20, image=self.img)
>
> def createW(self):
> self.C = Canvas(width=200, height=200)
> self.C.pack(TOP)
>
> app = App()
> app.mainloop()
More information about the Python-list
mailing list