Python Forum
[WxPython] Puzzled by classes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[WxPython] Puzzled by classes
#1
I have been learning to create GUI's using tkinter for some time and have created around 12 which I am happy with.
I have not used classes but see more and more examples of code using them.
I had not seen anything to persuade me to use classes or to change from using tkinter to using wxPython.
I found wxPython to be difficult for me to work with initially which is why I chose tkinter.
Recently I saw that wxPython seems to me very versatile so started to look here
Quote:http://zetcode.com/wxpython/menustoolbars/
Looking at these examples I cannot figure out how anything is instantiated.
The class is defined but seems to be used directly but I don't understand this:
def main():
    
    ex = wx.App()
    Example(None)
    ex.MainLoop()    
Could someone explain this please?
Thanks
Reply
#2
The Example class extends wx.Frame.  I don't know anything about wx, so I don't know if that's the recommended way to do things, but my guess is that if you don't pass it a parent window, wx will default to using whichever window was most recently created.  That's just a guess, though.
Reply
#3
(official doc on super)
Quote:Return a proxy object that delegates method calls to a parent or sibling class of type. This is useful for accessing inherited methods that have been overridden in a class. The search order is same as that used by
[url=https://docs.python.org/2/library/functions.html#getattr]getattr()[/url]
except that the type itself is skipped.

A very good explanation can be found here: https://www.blog.pythonlibrary.org/2014/...-is-super/

Personally, I try not to use *args and  **kwargs as they hide the attributes that are being used.
Reply
#4
(Aug-14-2017, 12:58 PM)Barrowman Wrote:
Example(None)
I think this is unrelated to super() and *args, since the window object is never even passed to the constructor in the first place, it's just None.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020