wxPython 4.0.2

efahl:

No, the ids returned by wx.NewId are not reserved and are outside the pool managed by wx.IdManager, so they cannot be "unreserved."

I thought as much, but of course that means NewControlId is not a viable replacement for NewId.

regards, Anders

I don’t understand your conclusion. NewControlId seems a perfect replacement for NewId. NewId comes from a small pool which, once used, cannot be reused. That makes it unsuitable for a fairly common use case where each new screen/panel makes a load of new widgets each with an ANY id, so NewIds used to run out even as the panels containing them were destroyed. Now ANY draws from a pool (NewControlID) which has the property of ids being returned which means in that case where panels are created and destroyed, the IDs go back in the pool. Unless you make more than the entire universe of IDs at the same time (as a poster here last week was trying to do), you don’t run out.

So the replacement for NewID is to reserve an ID, or more, from NewControlID. It won’t conflict with legacy code which uses NewID, it won’t conflict with any control which now uses a NewControlID. If you never want to release the IDs you choose, you don’t need to do so. If you are done with them, you can release them. You may still conflict with people using static IDs but if that happens they did something wrong in using them and there’s nothing you can do about this in any case.

The only use case I currently can think of by the way for actually bothering to reserve and set your own IDs at all is if you want to guarantee a consecutive range for ease of processing, in all other cases I’d just use ANY and bind to the value the framework gave me.

What sequence of events makes you think that NewControlId is not a viable replacement for NewID?

···

On 25 Jun 2018, at 20:06, Anders Munch <ajm@flonidan.dk> wrote:

efahl:

No, the ids returned by wx.NewId are not reserved and are outside the pool managed by wx.IdManager, so they cannot be "unreserved."

I thought as much, but of course that means NewControlId is not a viable replacement for NewId.

regards, Anders