Widget IDs

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

Widget IDs

Rich Shepard
   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

--
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: Widget IDs

Chris Barker - NOAA Federal


On Wed, Apr 25, 2018 at 9:51 AM, Rich Shepard <[hidden email]> wrote:
  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


 
  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 [hidden email].
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

[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: Widget IDs

Andrea Gavana
In reply to this post by Rich Shepard

On Wed, 25 Apr 2018 at 18.52, Rich Shepard <[hidden email]> wrote:
   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:

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.




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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
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: Widget IDs

Rich Shepard
In reply to this post by Chris Barker - NOAA Federal
On Wed, 25 Apr 2018, Chris Barker wrote:

> 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

--
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: Widget IDs

Rich Shepard
In reply to this post by Andrea Gavana
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.

Regards,

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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Widget IDs

Marc Tompkins
On Wed, Apr 25, 2018 at 10:27 AM, Rich Shepard <[hidden email]> 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...

--
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: Widget IDs

Marc Tompkins
On Wed, Apr 25, 2018 at 12:08 PM, Marc Tompkins <[hidden email]> wrote:
On Wed, Apr 25, 2018 at 10:27 AM, Rich Shepard <[hidden email]> 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...

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

--
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: Widget IDs

Scott Talbert
In reply to this post by Marc Tompkins
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...

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

--
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: Widget IDs

Tim Roberts
In reply to this post by Rich Shepard
Rich Shepard wrote:

> On Wed, 25 Apr 2018, Chris Barker 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.

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

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