I've created a function that responds to a button press. This function allows the user to look for an image file to upload into the application. Problem is, when the user wants to upload another image, the existing one stays behind and the new one is placed on top and so on and so fourth. How would I go about writing code to replace the old image with the new image, etc. I've thought this through and still cannot figure it out. I'm thinking maybe a global array? I'm stuck. Thanks
def importAlbumArt(self):
# import mp3s only
self.albumArt = askopenfilename(filetypes=[("JPEG Files", "*.jpeg"),("JPEG Files", "*.jpg"),("JPEG Files", "*.jif"),
("JPEG Files", "*.jfif"),("PNG Files", "*.png"),("GIF Files", "*.gif")])
load = Image.open(self.albumArt)
# place album art backdrop and change app status
#self.albumFrame.place(x=self.editFrame.winfo_width()/75, y=self.editFrame.winfo_height()/50)
self.status["text"] = "Album art imported"
self.albumFrame.update()
# resize image but maintain aspect ratio
new_width = 250
new_height = 250
old_width = load.size[0]
old_height = load.size[1]
new_width = new_height * old_width/old_height
new_height = new_width * old_height/old_width
load = load.resize((int(new_width),int(new_height)), Image.ANTIALIAS)
# render and place album art
render = ImageTk.PhotoImage(load)
img = (Label(self.editFrame, image=render))
img.image = render
img.grid(row=0, column=0, columnspan=2, rowspan=1)