Oct-23-2018, 12:55 AM
Here's the explanation as to why you had to do that:
In your original code, t_entry was a local variable inside the __init__() method. Therefore, when the method finished, it ceased to exist. Whereas, when you name it self.t_entry, it becomes an attribute of the Inv class and exists after the __init__() method has finished. Then, to call it up again, you treat it like any other class attribute and call up Inv.t_entry - which is self.t_entry within the methods of the Inv class.
In your original code, t_entry was a local variable inside the __init__() method. Therefore, when the method finished, it ceased to exist. Whereas, when you name it self.t_entry, it becomes an attribute of the Inv class and exists after the __init__() method has finished. Then, to call it up again, you treat it like any other class attribute and call up Inv.t_entry - which is self.t_entry within the methods of the Inv class.