Why my image cannot be displayed?
huey.y.jiang at gmail.com
huey.y.jiang at gmail.com
Fri Aug 12 21:40:03 EDT 2016
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!
More information about the Python-list
mailing list