Analysis and understanding of a tkinter code fragment
And our objective is to understand what's the importance/role in overriding the parent's class init() method with the indicated "master", if all of our internal widgets will won't exactly have the parent's class class as their master, instead the tkinter Tk() object.
If the internal widgets do not have self
or one of its descendants as its master, you should not be inheriting from tk.Frame
. There is simply no reason to inherit from any of the tk classes if all of the objects in that class are placed in the root window.
In other words, you should either
- inherit from
tk.Frame
and make all widgets created in__init__
be a child ofself
or one of it's descendants, or - do not inherit from tk.Frame, and place all of the widgets wherever you want.
Mixing those two techniques together makes no sense, and shouldn't be done.