memoize IDs

Yes, this use of IDs is one of the biggest warts in wxPython. Wouldn't
it be great if you could forget about IDs altogether?

That's what the Dabo folks thought, and that's the way that the Dabo
wrapper around wxPython works. I've created several apps that haven't
used a single ID at all. You might want to take a look at Dabo rather
than spending your time creating work-arounds to the shortcomings of
raw wxPython.

···

On 11/17/05, Julian Snitow <jsnitow@gmail.com> wrote:

Hello all,

I was going through the "Getting Started" section in the wxpython wiki
and noticed a lot of this:

ID_ABOUT=101
ID_EXIT=110 # note that ID_* = NewId() would still require these lines
# ... etc.

I, wxpython newb though I may be, humbly offer the following module,
which should render that practice obsolete.

--

# p.d.

   MyButton = wxButton(self, wx.ID_ANY, "push me")
   MyButton.Bind(wx.EVT_BUTTON, self.OnButtonPress)

It'd be nice not to have to type the "wx.ID_ANY", but it's a lot better
than keeping IDs around.

Well, you don't have to.

Let's have a look.

import wx
wx.ID_ANY

-1

help(wx.Button.__init__)

Help on method __init__ in module wx._controls:

__init__(self, *args, **kwargs) unbound wx._controls.Button method
    __init__(self, Window parent, int id=-1, String label=EmptyString,
        Point pos=DefaultPosition, Size size=DefaultSize,
        long style=0, Validator validator=DefaultValidator,
        String name=ButtonNameStr) -> Button

As you can see, wx.ID_ANY is just -1. And id is a keyword argument
that defaults to -1.

So, you can create a button like this:

MyButton = wx.Button(self, label='push me')

No IDs anywhere!

···

On 18/11/05, Chris Barker <Chris.Barker@noaa.gov> wrote:

--
John.