Sep-04-2022, 08:58 PM
(This post was last modified: Sep-04-2022, 08:58 PM by Gribouillis.)
(Sep-04-2022, 08:20 PM)AaronCatolico1 Wrote: Also, could you briefly explain why I have to put '(self)' into the 'create_btn.createBTN(self)' function?The function needs at least an argument that is the parent widget of the Button it creates. You could perhaps call this argument 'parent' instead of 'self'.
When developing the function, you may find that it needs to access methods of your instance of the Main class, for example it may want to call a method of that class, in that case, it would become necessary to pass this instance. The variable name 'self' is typically used only to denote the implicit instance of methods in classes, not external functions.
Another technique that you will learn when you have more experience with classes is that of Mixin classes, which are ways of extending existing classes with new methods that may come from another file. As you are only beginning to use classes, keep it simple.