Displaying images from url in tkinter [duplicate]
http://effbot.org/pyfaq/why-do-my-tkinter-images-not-appear.htmprovides an explanation.
When you add a PhotoImage or other Image object to a Tkinter widget, you must keep your own reference to the image object. If you don’t, the image won’t always show up.
The problem is that the Tkinter/Tk interface doesn’t handle references to Image objects properly; the Tk widget will hold a reference to the internal object, but Tkinter does not.
So something like this,
images = []for i in range(0, 8): ... raw_data = urllib.request.urlopen(cover).read() im = Image.open(io.BytesIO(raw_data)) image = ImageTk.PhotoImage(im) label1 = Label(mainWindow, image=image) label1.grid(row=i, sticky=W) # append to list in order to keep the reference images.append(image)mainWindow.mainloop()