I want to display an image from a URL in Tkinter. This is my current function:
def getImageFromURL(url):
print('hai')
raw_data = urlopen(url).read()
im = Image.open(BytesIO(raw_data))
image = ImageTk.PhotoImage(im)
return image
And the code where I am using this function is:
print(imgJSON[currentIndex])
img = getImageFromURL(imgJSON[currentIndex])
imagelab = tk.Label(self, image=img)
imagelab.image = img
imagelab.pack()
However, the code is making the tkinter window crash (Not Responding), but there are no errors. How would I fix this?