Re: Re: Preferred style
"'Chris Barker' via wxPython-users" <[email protected]> Sat, 3 Jul 2021 09:49:25 -0700
| Newsgroups | gmane.comp.python.wxpython |
|---|---|
| Message-ID | <CALGmxEKnOhsBdhogNmAY0_hLf+xvL4wKhkP7ANTMs92zL4suCw@mail.gmail.com> |
This: https://wiki.wxpython.org/wxPython%20Style%20Guide is very old, but still helpful. It would be really great if someone wants to update it for modern wx and modern style. -CHB On Thu, Apr 22, 2021 at 11:39 PM Steve Barnes <[email protected]> wrote: > Hi Phil, > > Glad if I helped. A couple of final points that may help. > > The use of -1 by wx & wxPython in some places as a parameter - the most > common place to see this is for the Windows ID - each window needs a unique > ID and in the Windows world that ID is an Unisigned Long type so Zero is a > valid ID (definitely not one that you want to use). Duplicating IDs causes > all sort of problems. You can manually set your windows IDs to values in > the User range and try to keep track of them yourself but that often > results in clashes accordingly wx & wxpython use an absolute value of -1 to > say "Please assign the next unused number in the permitted range" to wx - > this can also be spelt wx.ID_ANY which is preferable from a maintenance > point of view but is 9 keys rather than 2 - hence a lot of examples use -1. > If you look at the signature of wx.Frame you will see Frame(parent, > id=ID_ANY, title=EmptyString, pos=DefaultPosition, size=DefaultSize, > style=DEFAULT_FRAME_STYLE, name=FrameNameStr) but if you have imported wx > and just type wx.ID_ANY you will see an output of -1. > > The use of super - this is used to access and call parent class methods > usually those with the same name as a method that your class defines - > most commonly the __init__ method but it can be used for any method - > python 3 simplified the syntax for super, but still allows the older > syntax so you will often see super(parent_class, self).__init__(....) in > older or backwards compatible code rather than the newer > super().__init__(...). > > One of the joys of both Python and wx is the degree of backwards > compatibility that the developers have managed to maintain but sometimes it > does lead to outdated code examples, online and in books, that can cause > confusion. Note that whenever I have found old code that is "broken" by an > update and fix the issue usually it turns out to be that I was getting away > with doing something that I shouldn't have been and the fixed code still > works with the older versions of python & wx (but possibly not the very old > versions). > > All the best for your wxpython journey. > > Steve > > -----Original Message----- > From: [email protected] <[email protected]> > On Behalf Of Phil > Sent: 23 April 2021 02:04 > To: [email protected] > Subject: Re: [wxPython-users] Re: Preferred style > > On 22/4/21 3:44 pm, Steve Barnes wrote: > > > > Hi, > > > > I would encourage you to use pylint > > <https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fww > > w.pylint.org%2F&data=04%7C01%7C%7C46ecf246d9bb4a69aa0708d905f3bcb0 > > > %7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637547366658419079%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=uzb6A8LVwEcrEU4JT692sfx%2BCVST0YsCdG4gQhxCMVU%3D&reserved=0> > and possibly black < > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fblack.readthedocs.io%2Fen%2Fstable%2F&data=04%7C01%7C%7C46ecf246d9bb4a69aa0708d905f3bcb0%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637547366658419079%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=WqV2pJ6jX1PRg9taZvhXVW%2B%2Bd1SCNMA0tYKx4iiF9ZE%3D&reserved=0> > these will help to keep your style consistent and valid but there are a > number of other tools. > > Thank you Steve and RF for your replies, > > My question didn't really relate to formatting but more to the use of > "super", default arguments and the use of -1 as an argument in the > constructor. Your reply, Steve, has cleared up a couple of points that I > found confusing. More reading is required. > > I have used several different linters, formatters and IDEs over the years. > I recently installed VS Code and like it a lot. I'm now using Pylint and > Yapf. > > -- > > Regards, > Phil > > -- > 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 [email protected]. > To view this discussion on the web visit > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fwxpython-users%2Fd207bacc-5e53-9add-57c9-3f0bedc40b5c%2540gmail.com&data=04%7C01%7C%7C46ecf246d9bb4a69aa0708d905f3bcb0%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637547366658419079%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=qLTAT2IyYaqv2Ui9NELjHUsfA9iEEc9bROR5I7DhNqg%3D&reserved=0 > . > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/wxpython-users/VI1PR03MB447905F0461B378FB8E8C8C69B459%40VI1PR03MB4479.eurprd03.prod.outlook.com > . > -- 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 [email protected] -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/CALGmxEKnOhsBdhogNmAY0_hLf%2BxvL4wKhkP7ANTMs92zL4suCw%40mail.gmail.com.