How can I add a new option to an inherited tkinter Frame class? How can I add a new option to an inherited tkinter Frame class? tkinter tkinter

How can I add a new option to an inherited tkinter Frame class?


The problem is that you use kwargs not only in the for photo loop but also pass it to the init of tkinter.Frame in

tkinter.Frame.__init__(self, master, *args, **kwargs)

For tkinter.Frame photos is not a valid keyword argument and therefore the whole thing fails. A potential solution would be

class SlideShow(tkinter.Frame):    def __init__(self, master=None,photo_urls=[], *args, **kwargs):        tkinter.Frame.__init__(self, master, *args, **kwargs)        self.master = master        self.grid()        self.photos = []        for url in photo_urls:            self.photos.append(ImageTk.PhotoImage(Image.open(io.BytesIO(urlopen(url).read()))))        self.label_photo = tkinter.Label(self, image=self.photos[0])        self.label_photo.photo = self.photos[0]        self.label_photo.grid(column=1, row=1)

Make however shure that your code works also for an empty list of photos.