Mar-06-2021, 02:26 PM
I am confused by this
Inheritance affects which code runs when a method is called, but it is incorrect to say that calling a method of an object "inherits" something. I can ask a hardwareTab object for it's width and height for example. Your code does not define these methods, but they are defined by QWidget, and because they are methods of a superclass, they get inherited by hardwareTab. So you could say that inheritance affects how a method call is bound, how Python figures out what code to execute, but calling a method does not result in the caller "inheriting" anything.
I think any confusion you have about function calls and inheritance is caused by your enterNewHardware class. In some of your posts enterNewHardware was a function, and then later you made it a class. enterNewHardware() calls a function when enterNewHardware() is a function and it creates an instance of a class when enterNewHardware is a class. As a result, this code does really different things based on if enterNewHardware is a function or a class.
Quote:or if an outside function(function outside of a class) calls a class, again only inherits the methods of the class being called.
Inheritance affects which code runs when a method is called, but it is incorrect to say that calling a method of an object "inherits" something. I can ask a hardwareTab object for it's width and height for example. Your code does not define these methods, but they are defined by QWidget, and because they are methods of a superclass, they get inherited by hardwareTab. So you could say that inheritance affects how a method call is bound, how Python figures out what code to execute, but calling a method does not result in the caller "inheriting" anything.
I think any confusion you have about function calls and inheritance is caused by your enterNewHardware class. In some of your posts enterNewHardware was a function, and then later you made it a class. enterNewHardware() calls a function when enterNewHardware() is a function and it creates an instance of a class when enterNewHardware is a class. As a result, this code does really different things based on if enterNewHardware is a function or a class.
self.enButton.clicked.connect(enterNewHardware)If enterNewHardware is a function, pressing the button calls the function with no arguments. If enterNewHardware is a class, pressing the button creates a new instance of the class, and enterNewHardware.__init__() is called.