Widget IDs

In demos, tutorials, and application source code I've seen both '-1' and
'wx.ID_ANY' used for automatic generation of unique widget identification
codes.

   Does it matter (perhaps by context) when each is used?

Just curious,

Rich

  In demos, tutorials, and application source code I've seen both '-1' and
'wx.ID_ANY' used for automatic generation of unique widget identification
codes.

if you look, the value of wx.ID_ANY is -1

So they mean the same thing.

using the named constant is better style and more "future proof", but it's
been -1 for so long that I doubt it would ever change.

-CHB

···

On Wed, Apr 25, 2018 at 9:51 AM, Rich Shepard <rshepard@appl-ecosys.com> wrote:

  Does it matter (perhaps by context) when each is used?

Just curious,

Rich

--
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 wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

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

Chris.Barker@noaa.gov

In demos, tutorials, and application source code I’ve seen both ‘-1’ and

‘wx.ID_ANY’ used for automatic generation of unique widget identification

codes.

Does it matter (perhaps by context) when each is used?

No, I can’t think of any context in which you would prefer one to the other, except perhaps for code clarity (?).

As per
http://docs.wxwidgets.org/3.0/defs_8h.html , wxID_ANY is defined as equal to -1, so no issues here. There is a mention of it in the wxPython style guide:

https://wiki.wxpython.org/wxPython%20Style%20Guide

There is an utopian statement saying that the value of wxID_ANY might change in the future, but that may likely break billions of lines of code so it’s as likely as me flying to the moon tomorrow.

By the way, a simple google search would have told you this and so much more.

Andrea.

···

On Wed, 25 Apr 2018 at 18.52, Rich Shepard rshepard@appl-ecosys.com wrote:

Just curious,

Rich

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 wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

if you look, the value of wx.ID_ANY is -1. So they mean the same thing.

Chris,

   This is what I thought and why I wondered why both are used.

using the named constant is better style and more "future proof", but it's
been -1 for so long that I doubt it would ever change.

   This makes sense. And changing wouldn't yield any benefits. From my
perspective, while wx.ID_ANY has seven more characters to type it is
unambigouus and fits the style of other constants.

Thanks,

Rich

···

On Wed, 25 Apr 2018, Chris Barker wrote:

Andrea,

   I did search the web but the strings I chose did not provid the
information I sought.

Regards,

Rich

···

On Wed, 25 Apr 2018, Andrea Gavana wrote:

By the way, a simple google search would have told you this and so much
more.

relevant results within the first two pages.
I don't think we can blame Rich for not finding what he wanted to know -
these terms are just too nebulous for Google to get a handle on, I think.
As a fan of the band The The, this feels eerily familiar to me...

···

On Wed, Apr 25, 2018 at 10:27 AM, Rich Shepard <rshepard@appl-ecosys.com> wrote:

On Wed, 25 Apr 2018, Andrea Gavana wrote:

By the way, a simple google search would have told you this and so much

more.

Andrea,

  I did search the web but the strings I chose did not provid the
information I sought.

Out of curiosity, I tried Googling "wx.ANY", "wx.ANY" ID, etc. I get _no_

Of course, when I type it in the proper order - "wx.ID_ANY" - it does
work. Clumsy fingers and Googling are a bad combo.

···

On Wed, Apr 25, 2018 at 12:08 PM, Marc Tompkins <marc.tompkins@gmail.com> wrote:

On Wed, Apr 25, 2018 at 10:27 AM, Rich Shepard <rshepard@appl-ecosys.com> > wrote:

On Wed, 25 Apr 2018, Andrea Gavana wrote:

By the way, a simple google search would have told you this and so much

more.

Andrea,

  I did search the web but the strings I chose did not provid the
information I sought.

Out of curiosity, I tried Googling "wx.ANY", "wx.ANY" ID, etc. I get

_no_ relevant results within the first two pages.
I don't think we can blame Rich for not finding what he wanted to know -
these terms are just too nebulous for Google to get a handle on, I think.
As a fan of the band The The, this feels eerily familiar to me...

The first hit I get when Googling "wx.ID_ANY" is the wxPython Style Guide.

···

On Wed, 25 Apr 2018, Marc Tompkins wrote:

Out of curiosity, I tried Googling "wx.ANY", "wx.ANY" ID, etc. I get _no_
relevant results within the first two pages.
I don't think we can blame Rich for not finding what he wanted to know -
these terms are just too nebulous for Google to get a handle on, I think.
As a fan of the band The The, this feels eerily familiar to me...

Rich Shepard wrote:

if you look, the value of wx.ID_ANY is -1. So they mean the same thing.

This is what I thought and why I wondered why both are used.

using the named constant is better style and more "future proof", but
it's
been -1 for so long that I doubt it would ever change.

This makes sense. And changing wouldn't yield any benefits. From my
perspective, while wx.ID_ANY has seven more characters to type it is
unambigouus and fits the style of other constants.

This is a religious argument that probably has no "right" or "wrong"
answers. The exact same thing applies to wx.DefaultSize and
wx.DefaultPosition, both of which are identical to (-1,-1), and
wx.EmptyString, which is identical to "".

There is a general rule that you should never have bare integer
constants in your code. That's a good rule, although I'll admit I don't
always follow it when writing quick projects.

···

On Wed, 25 Apr 2018, Chris Barker wrote:

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.