I read this Style Guide for wxPython code which says:
3. Don't use IDs. There is very rarely a good reason to use them.
I've also seen a lot of wx.ID_ANY in application code.
Questions:
Why it's not recommended to use IDs?
Why doesn't the library simply hide IDs in the API if they shouldn't be used anyway?
You don't want to use hard-coded IDs because there are some that are reserved by wxPython itself. This is why we have wx.ID_ANY. This allows wxPython to grab an unused ID, which prevents collisions, which also prevents hard to find bugs.
Note that using wx.NewId is now deprecated and you should use wx.Window.NewControlId() in wxPython 4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With