Mar-23-2019, 10:22 PM
(Mar-22-2019, 11:33 PM)Larz60+ Wrote:Quote:I am trying to understand the process by which widgets are added to the GUI using classes in this manner.You really should spend some time learning about classes in general.
a widget is a class as a matter of fact everything in python is a class
To show this, consider this example:
>>> a = 5 >>> type(a) <class 'int'> >>>a is an instance of class int
as for widgets:
>>> import tkinter >>> root = tkinter.Tk() >>> type(root) <class 'tkinter.Tk'> >>> label_a = tkinter.Label(text='abc') >>> type(label_a) <class 'tkinter.Label'> >>> # If you want to see methods and attributes for Label: >>> help(tkinter.Label) ...here are some tutorials on classes:
Class Basics
Class Intermediate: Inheritance
Class Intermediate: Operator Overloading
Classes [advanced]: Dependent attributes (and Descriptors)
Classes [advanced]: Descriptors (managed attributes)
Reading up...
Search results for OOP and Python related material is flooded with all sorts of Udemy-related things. The docs don't seem to explain things in a way I can understand it, as most documentation I've seen tries to explain as little as possible.
(Mar-23-2019, 12:16 AM)Yoriz Wrote:(Mar-22-2019, 09:05 PM)Ceegen Wrote: what determines which frame that widget belongs to?when a widget is created it is passed a parent, the created widgets __init__ method then set the passed in widget as it parent, the widget then belongs to the passed in parent.
Okay. I'm going to go try a few things now in the code and see if I really understand what you're saying.
If I have any more questions as a result of that, I'll just come back to this thread.
Thanks x2.