Michael Driscoll, please fix wxPython Cookbook!

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Michael Driscoll, please fix wxPython Cookbook!

Boštjan Mejak-4
The book was published on 2016-12-06. I just wanted to buy the PDF version of it and said "Wait, I'm gonna read the free sample of it first". And what I found was... It is... (sighs)

Go to page 9:
1  loc = wx.Icon(r'C:\Python27\python.exe', 0)
A description of this line follows.

But the code on page 8 has this line:
10  loc = wx.IconLocation(r'C:\Python35\python.exe', 0)

Fix page 9 to have this:
10  loc = wx.IconLocation(r'C:\Python35\python.exe', 0)
You need to copy & paste, my friend! You didn't even display the correct line number of the code, so people may get confused. You wrote wx.Icon instead of wx.IconLocation. Even the path in this class' arguments is wrong, or at least not the same as in the line of code: people are mad now!

Just fix this and I'll buy your book.

The code style you're using: yuck! For a book, the code style in your book is garbage.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Michael Driscoll, please fix wxPython Cookbook!

Boštjan Mejak-4
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(). Also, add keyword argument names! Don't just write SomeClass(blah, None, blah_some_more)

This is ment to educate people about wxPython! How the hell would they know why do they need "None" as a second argument to wx.Frame.__init__() (or first argument if using the super() method), or how would they know what this "None" does. Just spell out "parent=None" and you tell everything. "Ah, the parent of my frame is None because this is a top-level frame and it doesn't need any parent," says the reader. Code in books as important as this need stupid-proof keyword argument names!

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Michael Driscoll, please fix wxPython Cookbook!

Chris Barker - NOAA Federal
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:


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:


Was written quite some time ago -- maybe it could use a review?

-CHB

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Michael Driscoll, please fix wxPython Cookbook!

Mike Driscoll


On Wednesday, March 22, 2017 at 10:49:27 AM UTC-5, Chris Barker - NOAA Federal wrote:
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:

I do have multiple ways of contacting me...this is probably one of the rudest ways. It should be noted that OP is known to behave this way though...

 

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.

Yeah, I almost used super() in this book, but decided against it. I have seen very few examples that use it and I didn't want my readers to be confused by a new syntax. I did mean to mention the differences though, so that is something I may add.

 

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)
    .....


The main reason I didn't do keyword arguments in a lot of the examples is because the line width can get too wide for the various book's formats. For example, the code examples might look fine in PDF, but they might look like garbage in mobi if the reader is using a phone. I can't mitigate all screen sizes of course, but I was trying for a nice middle ground. If I ever get around to writing my introductory book on wxPython, I will certainly consider adding those.
 
Mike

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Michael Driscoll, please fix wxPython Cookbook!

Chris Barker - NOAA Federal
On Fri, Mar 24, 2017 at 11:24 AM, Mike Driscoll <[hidden email]> wrote:


Well, tough to have to use less than an 80 character line. But when lines get long in general, I like to put the arguments on their own line anyway:

def __init__(self,
             parent=None,
             title='Python Image Title',
             size=(800,600),
             )


that should fit on a pretty small screen.

Also, trying to read a programming book in  format that doesn't support 80 characters on a line is kind of a lost cause anyway....

-CHB


--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[hidden email]

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Michael Driscoll, please fix wxPython Cookbook!

Mike Driscoll


On Friday, March 24, 2017 at 4:18:49 PM UTC-5, Chris Barker wrote:
On Fri, Mar 24, 2017 at 11:24 AM, Mike Driscoll <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="y6bQptTpAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">kyos...@...> wrote:


Well, tough to have to use less than an 80 character line. But when lines get long in general, I like to put the arguments on their own line anyway:

def __init__(self,
             parent=None,
             title='Python Image Title',
             size=(800,600),
             )


that should fit on a pretty small screen.

Also, trying to read a programming book in  format that doesn't support 80 characters on a line is kind of a lost cause anyway....


Oh, I totally agree. It's either going to be the lines are too long or the code is broke up across multiple pages. You can't make every one happy.

The people who have contacted me about this book have been happy with it though.

Mike

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.