If you don’t like Mike’s book, don’t buy it. There is no reason to be nasty about it – particularly in a public forum.
If you do have suggestions or corrections, There must be a way to contact him directly. Hopefully nicely.
However, this is an appropriate forum to discus what should be idiomatic wxPython, so:
Also, wx.Frame.init(self, None, title=‘Python Image Title’) and all other examples can be super().init(parent=None, title=‘Python Image Title’)
The code is much cleaner that way and if you’re dealing with multiple inheritance, you are golden with super().
We’ll, yes and no. super() is kind of ugly and confusing syntax ( in py3 anyway ), and the subclassing only works well if the superclasses are carefully designed to handle super properly.
I’ve vacillated about this myself for years, but tend to go back to the explicit call. And it’s particularly appropriate for a tutorial.
Also, add keyword argument names! Don’t just write SomeClass(blah, None, blah_some_more)
I agree here, but you can be nice about it.
It’s particularly important when you need to add extra parameters to a subclass.
I also prefer *args, **kwargs for passing the usual arguments on to the superclass:
def init( self, custom_arg, *args, **kwargs):
wx.Window.init(*args, **kwargs)
…
Then I use keyword arguments when I call it:
w = MyWindow(parent=self, size=(800, 600))
So you only need to pass the ones that aren’t default.
Pardon the typos, hard to write (or test) code on a phone!
BTW: if you want to provide the community with good examples of idiomatic wxPython code, going in an updating the wiki would be great.
I also have a substantial collection of demos here:
https://github.com/PythonCHB/wxPythonDemos
Those were written over a very long period of time, and the older ones have outdated ( and downright awful ) style, and may not even work anymore.
I’d really appreciate any PRs for improved style or functionality – It would be far more helpful to the community if they all had clean style and actually worked
One more opportunity:
The wiki page here:
https://wiki.wxpython.org/wxPython%20Style%20Guide
Was written quite some time ago – maybe it could use a review?
-CHB