-
-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GUI: fix crashing due to File menu translation issues #4513
Conversation
I don't think what I'm going to suggest below is better than this PR, but it is a reflexion. I find it weird that the menu items would be acted upon with translated titles as keys. I was searching to see if there would be an abstraction between what the menu item represents and the translated and displayed value was, but closest I got was title vs label, but couldn't answer myself on the difference. However, in this specific case of the file menu (or help, or about, etc), it seems that wx has some special handling for some common items, that are handled in a platform-specific manner (especially on mac). See the first example of https://wiki.wxpython.org/How%20to%20use%20the%20Internationalization%20-%20i18n%20%28Phoenix%29, where some predefined ids are used (wx.GetStockLabel(wx.ID_FILE)) def _createControls(self):
# A Statusbar in the bottom of the window
self.CreateStatusBar(1)
sMsg = 'wxPython ' + wx.version()
self.SetStatusText(sMsg)
# Menu bar
menubar = wx.MenuBar()
# File menu
filemenu = wx.Menu()
filemenu.Append(wx.ID_EXIT)
menubar.Append(filemenu, wx.GetStockLabel(wx.ID_FILE))
# Help menu
helpmenu = wx.Menu()
helpmenu.Append(wx.ID_ABOUT)
menubar.Append(helpmenu, wx.GetStockLabel(wx.ID_HELP))
self.SetMenuBar(menubar)
# Add a panel to the frame (needed under Windows to have a nice background)
pnl = wx.Panel(self, wx.ID_ANY)
szrMain = wx.BoxSizer(wx.VERTICAL)
szrMain.AddStretchSpacer(1)
label = wx.StaticText(pnl, wx.ID_STATIC, _("Welcome from wxWidgets"))
fnt = label.GetFont().MakeLarger().MakeLarger()
label.SetFont(fnt)
szrMain.Add(label, 0, wx.ALL|wx.ALIGN_CENTER, 10)
szrMain.AddStretchSpacer(1)
pnl.SetSizer(szrMain) The Ids are https://docs.wxpython.org/wx.StandardID.enumeration.html, GetStockLabel is described herehttps://docs.wxpython.org/wx.functions.html#wx.GetStockLabel, and (older) info on special ids is here https://wiki.wxpython.org/SpecialIDs. I know most of the docs for wxPython are old, but there has now been a change in maintainership since the beginning of September 2024, the original person was getting old and ill. Transfer of the infrastructure wasn't completed yet, but they released a version since. |
Yes, but the menu is generated from xml, so it's somewhat inconvenient to deal with the Stock IDs... |
Is there somewhere more info publicly on this? |
The README of the project, plus following the quite long threads when the community was trying to get in touch with the maintainers (maintainer), at one point where he responded. wxWidgets/Phoenix#2553, plus related threads, and some threads in a discourse forum of wxPython. At least one new maintainer can push to PyPI plus, and there are more than one person in GitHub organization (publicly). The release made the fixes for Python 3.12 available. At least since September, the bus factor isn't of 0 (some had even said that the bus has already past before the author's reply). |
Ok, I didn't know that for these, I knew about the dialogs for the modules though. But do you know what a label in the Menu (MenuBar or MenuItem?) would mean, compared to the title? |
What do you mean with title specifically, we don't use it anywhere, no? |
The menu.FindMenu refers to this function, right?
The menu.FindMenu refers to this function, right? https://docs.wxpython.org/wx.MenuBar.html#wx.MenuBar.FindMenu |
The doc says it uses either title or label, we don't use titles (whatever that is) so I don't see any issues. |
Ok, so anyways, this PR isn't wrong, so let's go forward with it. |
This should fix #3222 and a duplicate #4491. It tries to first find the translated version of File menu, if it fails, it looks for untranslated version. I could replicate #4491 and this fixes it, GUI starts again.