Dear all,
my App's GUI is internationalized. Choices (MenuItem objects) are dynamically created based on a config setting, in a for loop. The following lines are inside this loop, used to create the ID and assign it a value.
idname = ‘ID_LanguageMenu_{}’.format(localename)
globals()[idname] = wx.NewId()
.
.
.
self.Bind(wx.EVT_MENU, lambda event, args=(localename,): self.OnLanguageChange(event, *args), id=globals()[idname])
To all the MenuItems the same method is bound, that accepts the selected language as an input argument.
The code above works well, e.g. the id can be used to provide argument in the method bound to the generated MenuItems.
I tried to switch to wx.ID_ANY instead of wx.NewId(). This change resulted in always getting the last defined locale as input argument instead of the selected one.
Hope that my description is clear. wx.NewId() is a solution, however I’m curious what the reason might be.
All the best,
Gabor
Hi,
According to the documentation , wx.ID_ANY is used in situations where you don’t care what the ID is.
Turns out that wx.NewID is now depricated, and I’ve been using wx.NewIdRef().GetId() to great affect.
HTH,
···
Take care,
Chris Norman
Robin
May 20, 2019, 4:03pm
3
The last item in the MigrationGuide gives some more details: https://docs.wxpython.org/MigrationGuide.html#wx-newid-is-deprecated
···
On Saturday, May 18, 2019 at 4:04:36 PM UTC-7, Chris Norman wrote:
Hi,
According to the documentation , wx.ID_ANY is used in situations where you don’t care what the ID is.
Turns out that wx.NewID is now depricated, and I’ve been using wx.NewIdRef().GetId() to great affect.
–
Robin
Hi,
According to the documentation , wx.ID_ANY is used in situations where you don’t care what the ID is.
Turns out that wx.NewID is now depricated, and I’ve been using wx.NewIdRef().GetId() to great affect.
The last item in the MigrationGuide gives some more details: https://docs.wxpython.org/MigrationGuide.html#wx-newid-is-deprecated
That’s great, I’d forgotten about that page, thank you so much.
···
Take care,
Chris Norman
Mr. Dunn, Mr. Norman,
The error is obviously on my sinde for not reading and thinking, but doing.
I’ll check the migration page - I’ve never seen it before.
Thank you both for the advice.
All the best,
Gábor
···
On Mon, May 20, 2019 at 6:22 PM ‘Chris Norman’ via wxPython-users wxpython-users@googlegroups.com wrote:
On Mon, 20 May 2019 at 17:03, Robin Dunn robin@alldunn.com wrote:
On Saturday, May 18, 2019 at 4:04:36 PM UTC-7, Chris Norman wrote:
Hi,
According to the documentation , wx.ID_ANY is used in situations where you don’t care what the ID is.
Turns out that wx.NewID is now depricated, and I’ve been using wx.NewIdRef().GetId() to great affect.
The last item in the MigrationGuide gives some more details: https://docs.wxpython.org/MigrationGuide.html#wx-newid-is-deprecated
That’s great, I’d forgotten about that page, thank you so much.
–
Robin
–
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 .
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/dd0eb2e2-d437-41d9-9b85-65e4863ddacc%40googlegroups.com .
For more options, visit https://groups.google.com/d/optout .
–
Take care,
Chris Norman
–
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 .
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/CANjhqb8qOe0NwkOg4%2BGdkDxTo%2BXyUm2oVAeBH1%2BO9dnU_Ztbwg%40mail.gmail.com .
For more options, visit https://groups.google.com/d/optout .
I like this write up best: https://wxpython.org/blog/avoiding-window-ids/index.html
···
On Monday, May 20, 2019 at 1:41:26 PM UTC-7, Jakab Gábor wrote:
Mr. Dunn, Mr. Norman,
The error is obviously on my sinde for not reading and thinking, but doing.
I’ll check the migration page - I’ve never seen it before.
Thank you both for the advice.
All the best,
Gábor
On Mon, May 20, 2019 at 6:22 PM ‘Chris Norman’ via wxPython-users wxpytho...@googlegroups.com wrote:
On Mon, 20 May 2019 at 17:03, Robin Dunn ro...@alldunn.com wrote:
On Saturday, May 18, 2019 at 4:04:36 PM UTC-7, Chris Norman wrote:
Hi,
According to the documentation , wx.ID_ANY is used in situations where you don’t care what the ID is.
Turns out that wx.NewID is now depricated, and I’ve been using wx.NewIdRef().GetId() to great affect.
The last item in the MigrationGuide gives some more details: https://docs.wxpython.org/MigrationGuide.html#wx-newid-is-deprecated
That’s great, I’d forgotten about that page, thank you so much.
–
Robin
–
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 wxpytho...@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/dd0eb2e2-d437-41d9-9b85-65e4863ddacc%40googlegroups.com .
For more options, visit https://groups.google.com/d/optout .
–
Take care,
Chris Norman
–
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 wxpytho...@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/CANjhqb8qOe0NwkOg4%2BGdkDxTo%2BXyUm2oVAeBH1%2BO9dnU_Ztbwg%40mail.gmail.com .
For more options, visit https://groups.google.com/d/optout .