Feb-15-2022, 09:10 PM
I think this is a bad idea:
class ClassName(Tk.Frame): def __init__( self, parent, **options ): Tk.Frame.__init__( self, parent, **options ) options = {'bg': 'tan'} self.parent=parent self.canvas=Canvas(self,width=300,height=300,**options) self.canvas.grid(row=0,column=0)The appropriate way to do this is.
import tkinter as tk class ClassName(tk.Frame): def __init__(self, parent, canvas_bg=None, **kwargs): super().__init__(self, parent, **kwargs) self.canvas=tk.Canvas(self, width=300, height=300, bg=canvas_bg) self.canvas.grid(row=0,column=0) thing = ClassName(self, canvas_bg="tan", bg="yellow")Even if you end up with dozens of keyword arguments it is far better to expose them in the argument list than to hide them in and options dictionary.