Why my image cannot be displayed?
huey.y.jiang at gmail.com
huey.y.jiang at gmail.com
Sat Aug 13 19:30:39 EDT 2016
On Friday, August 12, 2016 at 9:40:15 PM UTC-4, huey.y... at gmail.com wrote:
> Hi All,
>
> Image display drives me crazy. After I get it displayed, and want to do the job with a class, display failed again. Please take a look at my trial code:
>
> from Tkinter import *
>
> class imageDisplay:
> def __init__(self, parent=None):
> canvas = Canvas(width=400, height=300, bg='beige')
> canvas.pack()
> self.canvas = canvas
> img = PhotoImage(file="xxx.gif")
> self.canvas.create_image(150, 0, image=img, anchor=NW)
>
> if __name__ == '__main__':
> imageDisplay()
> mainloop()
>
> Result: A blank canvas was displayed. No error message.
>
> Can somebody help? Thanks so much!
Thanks! it's working. Particularly thanks for your explanation!
More information about the Python-list
mailing list