Hello everyone,
I’m new to wxPython and Python OOP and i dont understand two thing in wxPython.
In the link below i show two examples of code related with two questions i have.
Link: wxPython question examples - Pastebin.com
The questions I have are probably caused by attempt to reference OOP Python tutorials I’ve watched to things which happens in wxPython.
Example 1 - First question
This example shows the bare minimum code to show a window with given title and size.
As far is I know I create an object “myframe” which is an object of “wx.Frame” class.
Thats probably true, because when i call “isinstance(myframe, wx.Frame)” i get in respond “True”.
If so how can I get the values of the attributes back?
In the tutorials and examples of OOP there is usually someting like this “print(object.attribute)”
Unfortunatelly when i try to “print(myframe.title)” i get an error claiming, that my object does not have such an attribute. I tried to get my values back by writing “myframe.dict” which in tutorials returns all attributes, but in this case returns empty set “{}”…
How is it possible, that “myframe” which is an object stores many values, such as title, size and so on without having even a single attribute? How can I get them (values i passed) so that I can use them later?
Example 2 - Second question
This example shows code rewritten form using classes and inheritance. Despite of things from first question I have one additional question.
First I create a “myframe” object of “MainFrame” class, which is a child of “wx.Frame” class. Additionally I add to this object one test attribute named “dog”. Then (from MainFrame class) I call constructor of “Textpanel” class which is child of “wx.StaticText” class.
The wxPython shows window with this text just like I wanted, but I don’t get how does it work.
When i call MainFrame constructor i assign it and in result I have “myframe” object. It exists and I can print my test attrubite “dog” by using “print(myframe.dog)”.
The thing I dont get is calling “Textpanel” from “MainFrame”. This call is assignet to nothig, so it should not exist. If so how is it possible for wxPython to display it? Where is it stored? How can i print my test attribute “cat” when I dont have an objet to call?
Thank you in advance for explanation, I hope someone will be able to do in an understandable way