diff --git a/source/core.py b/source/core.py index 0e77a9c6f4e..11888e7f254 100644 --- a/source/core.py +++ b/source/core.py @@ -1,10 +1,13 @@ -# -*- coding: UTF-8 -*- # A part of NonVisual Desktop Access (NVDA) -# Copyright (C) 2006-2019 NV Access Limited, Aleksey Sadovoy, Christopher Toth, Joseph Lee, Peter Vágner, +# Copyright (C) 2006-2021 NV Access Limited, Aleksey Sadovoy, Christopher Toth, Joseph Lee, Peter Vágner, # Derek Riemer, Babbage B.V., Zahari Yurukov, Łukasz Golonka # This file is covered by the GNU General Public License. # See the file COPYING for more details. +from typing import Optional, TYPE_CHECKING +if TYPE_CHECKING: + import wx + """NVDA core""" RPC_E_CALL_CANCELED = -2147418110 @@ -207,6 +210,27 @@ def _setInitialFocus(): except: log.exception("Error retrieving initial focus") + +def getWxLangOrNone() -> Optional[wx.LanguageInfo]: + import languageHandler + import wx + lang = languageHandler.getLanguage() + locale = wx.Locale() + wxLang = locale.FindLanguageInfo(lang) + if not wxLang and '_' in lang: + wxLang = locale.FindLanguageInfo(lang.split('_')[0]) + # #8064: Wx might know the language, but may not actually contain a translation database for that language. + # If we try to initialize this language, wx will show a warning dialog. + # #9089: some languages (such as Aragonese) do not have language info, causing language getter to fail. + # In this case, wxLang is already set to None. + # Therefore treat these situations like wx not knowing the language at all. + if wxLang and not locale.IsAvailable(wxLang.Language): + wxLang = None + if not wxLang: + log.debugWarning("wx does not support language %s" % lang) + return wxLang + + def main(): """NVDA's core main loop. This initializes all modules such as audio, IAccessible, keyboard, mouse, and GUI. @@ -418,26 +442,14 @@ def handlePowerStatusChange(self): # initialize wxpython localization support locale = wx.Locale() - lang=languageHandler.getLanguage() - wxLang=locale.FindLanguageInfo(lang) - if not wxLang and '_' in lang: - wxLang=locale.FindLanguageInfo(lang.split('_')[0]) + wxLang = getWxLangOrNone() if hasattr(sys,'frozen'): locale.AddCatalogLookupPathPrefix(os.path.join(globalVars.appDir, "locale")) - # #8064: Wx might know the language, but may not actually contain a translation database for that language. - # If we try to initialize this language, wx will show a warning dialog. - # #9089: some languages (such as Aragonese) do not have language info, causing language getter to fail. - # In this case, wxLang is already set to None. - # Therefore treat these situations like wx not knowing the language at all. - if wxLang and not locale.IsAvailable(wxLang.Language): - wxLang=None if wxLang: try: locale.Init(wxLang.Language) except: log.error("Failed to initialize wx locale",exc_info=True) - else: - log.debugWarning("wx does not support language %s" % lang) log.debug("Initializing garbageHandler") garbageHandler.initialize() diff --git a/source/gui/__init__.py b/source/gui/__init__.py index 368e537acd5..6cbe8c2ac02 100644 --- a/source/gui/__init__.py +++ b/source/gui/__init__.py @@ -596,6 +596,10 @@ def initialize(): if mainFrame: raise RuntimeError("GUI already initialized") mainFrame = MainFrame() + wxLang = core.getWxLangOrNone() + if wxLang: + # otherwise the system default will be used + mainFrame.SetLayoutDirection(wxLang.LayoutDirection) wx.GetApp().SetTopWindow(mainFrame) # In wxPython >= 4.1, # wx.CallAfter no longer executes callbacks while NVDA's main thread is within apopup menu or message box. @@ -725,14 +729,10 @@ def __init__(self, parent): welcomeTextDetail = wx.StaticText(self, wx.ID_ANY, self.WELCOME_MESSAGE_DETAIL) mainSizer.Add(welcomeTextDetail,border=20,flag=wx.EXPAND|wx.LEFT|wx.RIGHT) - optionsSizer = wx.StaticBoxSizer( - wx.StaticBox( - self, - # Translators: The label for a group box containing the NVDA welcome dialog options. - label=_("Options") - ), - wx.VERTICAL - ) + # Translators: The label for a group box containing the NVDA welcome dialog options. + optionsLabel = _("Options") + optionsSizer = wx.StaticBoxSizer(wx.VERTICAL, self, label=optionsLabel) + optionsBox = optionsSizer.GetStaticBox() sHelper = guiHelper.BoxSizerHelper(self, sizer=optionsSizer) # Translators: The label of a combobox in the Welcome dialog. kbdLabelText = _("&Keyboard layout:") @@ -747,17 +747,18 @@ def __init__(self, parent): log.error("Could not set Keyboard layout list to current layout",exc_info=True) # Translators: The label of a checkbox in the Welcome dialog. capsAsNVDAModifierText = _("&Use CapsLock as an NVDA modifier key") - self.capsAsNVDAModifierCheckBox = sHelper.addItem(wx.CheckBox(self, label=capsAsNVDAModifierText)) + self.capsAsNVDAModifierCheckBox = sHelper.addItem(wx.CheckBox(optionsBox, label=capsAsNVDAModifierText)) self.capsAsNVDAModifierCheckBox.SetValue(config.conf["keyboard"]["useCapsLockAsNVDAModifierKey"]) # Translators: The label of a checkbox in the Welcome dialog. startAfterLogonText = _("St&art NVDA after I sign in") - self.startAfterLogonCheckBox = sHelper.addItem(wx.CheckBox(self, label=startAfterLogonText)) + self.startAfterLogonCheckBox = sHelper.addItem(wx.CheckBox(optionsBox, label=startAfterLogonText)) self.startAfterLogonCheckBox.Value = config.getStartAfterLogon() if globalVars.appArgs.secure or config.isAppX or not config.isInstalledCopy(): self.startAfterLogonCheckBox.Disable() # Translators: The label of a checkbox in the Welcome dialog. showWelcomeDialogAtStartupText = _("&Show this dialog when NVDA starts") - self.showWelcomeDialogAtStartupCheckBox = sHelper.addItem(wx.CheckBox(self, label=showWelcomeDialogAtStartupText)) + _showWelcomeDialogAtStartupCheckBox = wx.CheckBox(optionsBox, label=showWelcomeDialogAtStartupText) + self.showWelcomeDialogAtStartupCheckBox = sHelper.addItem(_showWelcomeDialogAtStartupCheckBox) self.showWelcomeDialogAtStartupCheckBox.SetValue(config.conf["general"]["showWelcomeDialogAtStartup"]) mainSizer.Add(optionsSizer, border=guiHelper.BORDER_FOR_DIALOGS, flag=wx.ALL) mainSizer.Add(self.CreateButtonSizer(wx.OK), border=guiHelper.BORDER_FOR_DIALOGS, flag=wx.ALL|wx.ALIGN_RIGHT) @@ -810,7 +811,8 @@ def __init__(self, parent): # Translators: The label of the license text which will be shown when NVDA installation program starts. groupLabel = _("License Agreement") - sizer = sHelper.addItem(wx.StaticBoxSizer(wx.StaticBox(self, label=groupLabel), wx.VERTICAL)) + sizer = wx.StaticBoxSizer(wx.VERTICAL, self, label=groupLabel) + sHelper.addItem(sizer) licenseTextCtrl = wx.TextCtrl(self, size=(500, 400), style=wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_RICH) licenseTextCtrl.Value = codecs.open(getDocFilePath("copying.txt", False), "r", encoding="UTF-8").read() sizer.Add(licenseTextCtrl) diff --git a/source/gui/configProfiles.py b/source/gui/configProfiles.py index ceb20ae0b3c..63417fad3c3 100644 --- a/source/gui/configProfiles.py +++ b/source/gui/configProfiles.py @@ -42,13 +42,16 @@ def __init__(self, parent): mainSizer = wx.BoxSizer(wx.VERTICAL) sHelper = guiHelper.BoxSizerHelper(self,orientation=wx.VERTICAL) - profilesListGroupSizer = wx.StaticBoxSizer(wx.StaticBox(self), wx.HORIZONTAL) + profilesListGroupSizer = wx.StaticBoxSizer(wx.HORIZONTAL, self) + profilesListBox = profilesListGroupSizer.GetStaticBox() profilesListGroupContents = wx.BoxSizer(wx.HORIZONTAL) #contains the profile list and activation button in vertical arrangement. changeProfilesSizer = wx.BoxSizer(wx.VERTICAL) - item = self.profileList = wx.ListBox(self, - choices=[self.getProfileDisplay(name, includeStates=True) for name in self.profileNames]) + item = self.profileList = wx.ListBox( + profilesListBox, + choices=[self.getProfileDisplay(name, includeStates=True) for name in self.profileNames] + ) self.bindHelpEvent("ProfilesBasicManagement", self.profileList) item.Bind(wx.EVT_LISTBOX, self.onProfileListChoice) item.Selection = self.profileNames.index(config.conf.profiles[-1].name) @@ -56,7 +59,7 @@ def __init__(self, parent): changeProfilesSizer.AddSpacer(guiHelper.SPACE_BETWEEN_BUTTONS_VERTICAL) - self.changeStateButton = wx.Button(self) + self.changeStateButton = wx.Button(profilesListBox) self.bindHelpEvent("ConfigProfileManual", self.changeStateButton) self.changeStateButton.Bind(wx.EVT_BUTTON, self.onChangeState) self.AffirmativeId = self.changeStateButton.Id @@ -68,17 +71,17 @@ def __init__(self, parent): buttonHelper = guiHelper.ButtonHelper(wx.VERTICAL) # Translators: The label of a button to create a new configuration profile. - newButton = buttonHelper.addButton(self, label=_("&New")) + newButton = buttonHelper.addButton(profilesListBox, label=_("&New")) self.bindHelpEvent("ProfilesCreating", newButton) newButton.Bind(wx.EVT_BUTTON, self.onNew) # Translators: The label of a button to rename a configuration profile. - self.renameButton = buttonHelper.addButton(self, label=_("&Rename")) + self.renameButton = buttonHelper.addButton(profilesListBox, label=_("&Rename")) self.bindHelpEvent("ProfilesBasicManagement", self.renameButton) self.renameButton.Bind(wx.EVT_BUTTON, self.onRename) # Translators: The label of a button to delete a configuration profile. - self.deleteButton = buttonHelper.addButton(self, label=_("&Delete")) + self.deleteButton = buttonHelper.addButton(profilesListBox, label=_("&Delete")) self.bindHelpEvent("ProfilesBasicManagement", self.deleteButton) self.deleteButton.Bind(wx.EVT_BUTTON, self.onDelete) diff --git a/source/gui/guiHelper.py b/source/gui/guiHelper.py index b33edad2875..7531d682300 100644 --- a/source/gui/guiHelper.py +++ b/source/gui/guiHelper.py @@ -324,7 +324,10 @@ def addLabeledControl(self, labelText, wxCtrlClass, **kwargs): Relies on guiHelper.LabeledControlHelper and thus guiHelper.associateElements, and therefore inherits any limitations from there. """ - labeledControl = LabeledControlHelper(self._parent, labelText, wxCtrlClass, **kwargs) + parent = self._parent + if isinstance(self.sizer, wx.StaticBoxSizer): + parent = self.sizer.GetStaticBox() + labeledControl = LabeledControlHelper(parent, labelText, wxCtrlClass, **kwargs) if(isinstance(labeledControl.control, (wx.ListCtrl,wx.ListBox,wx.TreeCtrl))): self.addItem(labeledControl.sizer, flag=wx.EXPAND, proportion=1) else: @@ -345,6 +348,9 @@ def addDialogDismissButtons(self, buttons, separated=False): Should be set to L{False} for message or single input dialogs, L{True} otherwise. @type separated: L{bool} """ + parent = self._parent + if isinstance(self.sizer, wx.StaticBoxSizer): + parent = self.sizer.GetStaticBox() if self.sizer.GetOrientation() != wx.VERTICAL: raise NotImplementedError( "Adding dialog dismiss buttons to a horizontal BoxSizerHelper is not implemented." @@ -354,11 +360,11 @@ def addDialogDismissButtons(self, buttons, separated=False): elif isinstance(buttons, (wx.Sizer, wx.Button)): toAdd = buttons elif isinstance(buttons, int): - toAdd = self._parent.CreateButtonSizer(buttons) + toAdd = parent.CreateButtonSizer(buttons) else: raise NotImplementedError("Unknown type: {}".format(buttons)) if separated: - self.addItem(wx.StaticLine(self._parent), flag=wx.EXPAND) + self.addItem(wx.StaticLine(parent), flag=wx.EXPAND) self.addItem(toAdd, flag=wx.ALIGN_RIGHT) self.dialogDismissButtonsAdded = True return buttons @@ -366,4 +372,3 @@ def addDialogDismissButtons(self, buttons, separated=False): class SIPABCMeta(wx.siplib.wrappertype, ABCMeta): """Meta class to be used for wx subclasses with abstract methods.""" pass - diff --git a/source/gui/installerGui.py b/source/gui/installerGui.py index 8c7fd3e6377..8fbd861f935 100644 --- a/source/gui/installerGui.py +++ b/source/gui/installerGui.py @@ -175,18 +175,15 @@ def __init__(self, parent, isUpdate): self.bindHelpEvent("InstallWithIncompatibleAddons", self.confirmationCheckbox) self.confirmationCheckbox.SetFocus() - optionsSizer = guiHelper.BoxSizerHelper(self, sizer=sHelper.addItem(wx.StaticBoxSizer( - wx.StaticBox( - self, - # Translators: The label for a group box containing the NVDA installation dialog options. - label=_("Options") - ), - wx.VERTICAL - ))) + # Translators: The label for a group box containing the NVDA installation dialog options. + optionsLabel = _("Options") + optionsHelper = sHelper.addItem(wx.StaticBoxSizer(wx.VERTICAL, self, label=optionsLabel)) + optionsSizer = guiHelper.BoxSizerHelper(self, sizer=optionsHelper) + optionsBox = optionsSizer.GetStaticBox() # Translators: The label of a checkbox option in the Install NVDA dialog. startOnLogonText = _("Use NVDA during sign-in") - self.startOnLogonCheckbox = optionsSizer.addItem(wx.CheckBox(self, label=startOnLogonText)) + self.startOnLogonCheckbox = optionsSizer.addItem(wx.CheckBox(optionsBox, label=startOnLogonText)) self.bindHelpEvent("StartAtWindowsLogon", self.startOnLogonCheckbox) if globalVars.appArgs.enableStartOnLogon is not None: self.startOnLogonCheckbox.Value = globalVars.appArgs.enableStartOnLogon @@ -197,19 +194,22 @@ def __init__(self, parent, isUpdate): if self.isUpdate and shortcutIsPrevInstalled: # Translators: The label of a checkbox option in the Install NVDA dialog. keepShortCutText = _("&Keep existing desktop shortcut") - self.createDesktopShortcutCheckbox = optionsSizer.addItem(wx.CheckBox(self, label=keepShortCutText)) + keepShortCutBox = wx.CheckBox(optionsBox, label=keepShortCutText) + self.createDesktopShortcutCheckbox = optionsSizer.addItem(keepShortCutBox) else: # Translators: The label of the option to create a desktop shortcut in the Install NVDA dialog. # If the shortcut key has been changed for this locale, # this change must also be reflected here. createShortcutText = _("Create &desktop icon and shortcut key (control+alt+n)") - self.createDesktopShortcutCheckbox = optionsSizer.addItem(wx.CheckBox(self, label=createShortcutText)) + createShortcutBox = wx.CheckBox(optionsBox, label=createShortcutText) + self.createDesktopShortcutCheckbox = optionsSizer.addItem(createShortcutBox) self.bindHelpEvent("CreateDesktopShortcut", self.createDesktopShortcutCheckbox) self.createDesktopShortcutCheckbox.Value = shortcutIsPrevInstalled if self.isUpdate else True # Translators: The label of a checkbox option in the Install NVDA dialog. createPortableText = _("Copy &portable configuration to current user account") - self.copyPortableConfigCheckbox = optionsSizer.addItem(wx.CheckBox(self, label=createPortableText)) + createPortableBox = wx.CheckBox(optionsBox, label=createPortableText) + self.copyPortableConfigCheckbox = optionsSizer.addItem(createPortableBox) self.bindHelpEvent("CopyPortableConfigurationToCurrentUserAccount", self.copyPortableConfigCheckbox) self.copyPortableConfigCheckbox.Value = bool(globalVars.appArgs.copyPortableConfig) if globalVars.appArgs.copyPortableConfig is None: @@ -220,12 +220,12 @@ def __init__(self, parent, isUpdate): bHelper = sHelper.addDialogDismissButtons(guiHelper.ButtonHelper(wx.HORIZONTAL)) if shouldAskAboutAddons: # Translators: The label of a button to launch the add-on compatibility review dialog. - reviewAddonButton = bHelper.addButton(self, label=_("&Review add-ons...")) + reviewAddonButton = bHelper.addButton(optionsBox, label=_("&Review add-ons...")) self.bindHelpEvent("InstallWithIncompatibleAddons", reviewAddonButton) reviewAddonButton.Bind(wx.EVT_BUTTON, self.onReviewAddons) # Translators: The label of a button to continue with the operation. - continueButton = bHelper.addButton(self, label=_("&Continue"), id=wx.ID_OK) + continueButton = bHelper.addButton(optionsBox, label=_("&Continue"), id=wx.ID_OK) continueButton.SetDefault() continueButton.Bind(wx.EVT_BUTTON, self.onInstall) if shouldAskAboutAddons: @@ -235,7 +235,7 @@ def __init__(self, parent, isUpdate): ) continueButton.Enable(False) - bHelper.addButton(self, id=wx.ID_CANCEL) + bHelper.addButton(optionsBox, id=wx.ID_CANCEL) # If we bind this using button.Bind, it fails to trigger when the dialog is closed. self.Bind(wx.EVT_BUTTON, self.onCancel, id=wx.ID_CANCEL) @@ -349,35 +349,38 @@ def __init__(self, parent): # Translators: The label of a grouping containing controls to select the destination directory # in the Create Portable NVDA dialog. directoryGroupText = _("Portable &directory:") - groupHelper = sHelper.addItem(gui.guiHelper.BoxSizerHelper(self, sizer=wx.StaticBoxSizer(wx.StaticBox(self, label=directoryGroupText), wx.VERTICAL))) + groupSizer = wx.StaticBoxSizer(wx.VERTICAL, self, label=directoryGroupText) + groupHelper = sHelper.addItem(gui.guiHelper.BoxSizerHelper(self, sizer=groupSizer)) + groupBox = groupSizer.GetStaticBox() # Translators: The label of a button to browse for a directory. browseText = _("Browse...") # Translators: The title of the dialog presented when browsing for the # destination directory when creating a portable copy of NVDA. dirDialogTitle = _("Select portable directory") - directoryEntryControl = groupHelper.addItem(gui.guiHelper.PathSelectionHelper(self, browseText, dirDialogTitle)) + directoryPathHelper = gui.guiHelper.PathSelectionHelper(groupBox, browseText, dirDialogTitle) + directoryEntryControl = groupHelper.addItem(directoryPathHelper) self.portableDirectoryEdit = directoryEntryControl.pathControl if globalVars.appArgs.portablePath: self.portableDirectoryEdit.Value = globalVars.appArgs.portablePath # Translators: The label of a checkbox option in the Create Portable NVDA dialog. copyConfText = _("Copy current &user configuration") - self.copyUserConfigCheckbox = sHelper.addItem(wx.CheckBox(self, label=copyConfText)) + self.copyUserConfigCheckbox = sHelper.addItem(wx.CheckBox(groupBox, label=copyConfText)) self.copyUserConfigCheckbox.Value = False if globalVars.appArgs.launcher: self.copyUserConfigCheckbox.Disable() # Translators: The label of a checkbox option in the Create Portable NVDA dialog. startAfterCreateText = _("&Start the new portable copy after creation") - self.startAfterCreateCheckbox = sHelper.addItem(wx.CheckBox(self, label=startAfterCreateText)) + self.startAfterCreateCheckbox = sHelper.addItem(wx.CheckBox(groupBox, label=startAfterCreateText)) self.startAfterCreateCheckbox.Value = False bHelper = sHelper.addDialogDismissButtons(gui.guiHelper.ButtonHelper(wx.HORIZONTAL), separated=True) - continueButton = bHelper.addButton(self, label=_("&Continue"), id=wx.ID_OK) + continueButton = bHelper.addButton(groupBox, label=_("&Continue"), id=wx.ID_OK) continueButton.SetDefault() continueButton.Bind(wx.EVT_BUTTON, self.onCreatePortable) - bHelper.addButton(self, id=wx.ID_CANCEL) + bHelper.addButton(groupBox, id=wx.ID_CANCEL) # If we bind this using button.Bind, it fails to trigger when the dialog is closed. self.Bind(wx.EVT_BUTTON, self.onCancel, id=wx.ID_CANCEL) diff --git a/source/gui/settingsDialogs.py b/source/gui/settingsDialogs.py index 4b0a9dc40fa..92f03254e83 100644 --- a/source/gui/settingsDialogs.py +++ b/source/gui/settingsDialogs.py @@ -909,8 +909,9 @@ def makeSettings(self, settingsSizer): settingsSizerHelper = guiHelper.BoxSizerHelper(self, sizer=settingsSizer) # Translators: A label for the synthesizer on the speech panel. synthLabel = _("&Synthesizer") - synthBox = wx.StaticBox(self, label=synthLabel) - synthGroup = guiHelper.BoxSizerHelper(self, sizer=wx.StaticBoxSizer(synthBox, wx.HORIZONTAL)) + synthBoxSizer = wx.StaticBoxSizer(wx.HORIZONTAL, self, label=synthLabel) + synthBox = synthBoxSizer.GetStaticBox() + synthGroup = guiHelper.BoxSizerHelper(self, sizer=synthBoxSizer) settingsSizerHelper.addItem(synthGroup) # Use a ExpandoTextCtrl because even when readonly it accepts focus from keyboard, which @@ -919,12 +920,17 @@ def makeSettings(self, settingsSizer): # and a vertical scroll bar. This is not neccessary for the single line of text we wish to # display here. synthDesc = getSynth().description - self.synthNameCtrl = ExpandoTextCtrl(self, size=(self.scaleSize(250), -1), value=synthDesc, style=wx.TE_READONLY) + self.synthNameCtrl = ExpandoTextCtrl( + synthBox, + size=(self.scaleSize(250), -1), + value=synthDesc, + style=wx.TE_READONLY, + ) self.synthNameCtrl.Bind(wx.EVT_CHAR_HOOK, self._enterTriggersOnChangeSynth) # Translators: This is the label for the button used to change synthesizer, # it appears in the context of a synthesizer group on the speech settings panel. - changeSynthBtn = wx.Button(self, label=_("C&hange...")) + changeSynthBtn = wx.Button(synthBox, label=_("C&hange...")) self.bindHelpEvent("SpeechSettingsChange", self.synthNameCtrl) self.bindHelpEvent("SpeechSettingsChange", changeSynthBtn) synthGroup.addItem( @@ -2116,32 +2122,34 @@ def makeSettings(self, settingsSizer): # Translators: This is the label for a group of document formatting options in the # document formatting settings panel fontGroupText = _("Font") - fontGroup = guiHelper.BoxSizerHelper(self, sizer=wx.StaticBoxSizer(wx.StaticBox(self, label=fontGroupText), wx.VERTICAL)) + fontGroupSizer = wx.StaticBoxSizer(wx.VERTICAL, self, label=fontGroupText) + fontGroupBox = fontGroupSizer.GetStaticBox() + fontGroup = guiHelper.BoxSizerHelper(self, sizer=fontGroupSizer) sHelper.addItem(fontGroup) # Translators: This is the label for a checkbox in the # document formatting settings panel. fontNameText = _("&Font name") - self.fontNameCheckBox=fontGroup.addItem(wx.CheckBox(self, label=fontNameText)) + self.fontNameCheckBox = fontGroup.addItem(wx.CheckBox(fontGroupBox, label=fontNameText)) self.fontNameCheckBox.SetValue(config.conf["documentFormatting"]["reportFontName"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. fontSizeText = _("Font &size") - self.fontSizeCheckBox=fontGroup.addItem(wx.CheckBox(self,label=fontSizeText)) + self.fontSizeCheckBox = fontGroup.addItem(wx.CheckBox(fontGroupBox, label=fontSizeText)) self.fontSizeCheckBox.SetValue(config.conf["documentFormatting"]["reportFontSize"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. fontAttributesText = _("Font attrib&utes") - self.fontAttrsCheckBox=fontGroup.addItem(wx.CheckBox(self,label=fontAttributesText)) + self.fontAttrsCheckBox = fontGroup.addItem(wx.CheckBox(fontGroupBox, label=fontAttributesText)) self.fontAttrsCheckBox.SetValue(config.conf["documentFormatting"]["reportFontAttributes"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. superscriptsAndSubscriptsText = _("Su&perscripts and subscripts") self.superscriptsAndSubscriptsCheckBox = fontGroup.addItem( - wx.CheckBox(self, label=superscriptsAndSubscriptsText) + wx.CheckBox(fontGroupBox, label=superscriptsAndSubscriptsText) ) self.superscriptsAndSubscriptsCheckBox.SetValue( config.conf["documentFormatting"]["reportSuperscriptsAndSubscripts"] @@ -2150,14 +2158,14 @@ def makeSettings(self, settingsSizer): # Translators: This is the label for a checkbox in the # document formatting settings panel. emphasisText=_("E&mphasis") - self.emphasisCheckBox=fontGroup.addItem(wx.CheckBox(self,label=emphasisText)) + self.emphasisCheckBox = fontGroup.addItem(wx.CheckBox(fontGroupBox, label=emphasisText)) self.emphasisCheckBox.SetValue(config.conf["documentFormatting"]["reportEmphasis"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. highlightText = _("Mar&ked (highlighted text)") self.highlightCheckBox = fontGroup.addItem( - wx.CheckBox(self, label=highlightText) + wx.CheckBox(fontGroupBox, label=highlightText) ) self.highlightCheckBox.SetValue( config.conf["documentFormatting"]["reportHighlight"] @@ -2166,55 +2174,59 @@ def makeSettings(self, settingsSizer): # Translators: This is the label for a checkbox in the # document formatting settings panel. styleText =_("St&yle") - self.styleCheckBox=fontGroup.addItem(wx.CheckBox(self,label=styleText)) + self.styleCheckBox = fontGroup.addItem(wx.CheckBox(fontGroupBox, label=styleText)) self.styleCheckBox.SetValue(config.conf["documentFormatting"]["reportStyle"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. colorsText = _("&Colors") - self.colorCheckBox=fontGroup.addItem(wx.CheckBox(self,label=colorsText)) + self.colorCheckBox = fontGroup.addItem(wx.CheckBox(fontGroupBox, label=colorsText)) self.colorCheckBox.SetValue(config.conf["documentFormatting"]["reportColor"]) # Translators: This is the label for a group of document formatting options in the # document formatting settings panel documentInfoGroupText = _("Document information") - docInfoGroup = guiHelper.BoxSizerHelper(self, sizer=wx.StaticBoxSizer(wx.StaticBox(self, label=documentInfoGroupText), wx.VERTICAL)) + docInfoSizer = wx.StaticBoxSizer(wx.VERTICAL, self, label=documentInfoGroupText) + docInfoBox = docInfoSizer.GetStaticBox() + docInfoGroup = guiHelper.BoxSizerHelper(self, sizer=docInfoSizer) sHelper.addItem(docInfoGroup) # Translators: This is the label for a checkbox in the # document formatting settings panel. commentsText = _("No&tes and comments") - self.commentsCheckBox=docInfoGroup.addItem(wx.CheckBox(self,label=commentsText)) + self.commentsCheckBox = docInfoGroup.addItem(wx.CheckBox(docInfoBox, label=commentsText)) self.commentsCheckBox.SetValue(config.conf["documentFormatting"]["reportComments"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. revisionsText = _("&Editor revisions") - self.revisionsCheckBox=docInfoGroup.addItem(wx.CheckBox(self,label=revisionsText)) + self.revisionsCheckBox = docInfoGroup.addItem(wx.CheckBox(docInfoBox, label=revisionsText)) self.revisionsCheckBox.SetValue(config.conf["documentFormatting"]["reportRevisions"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. spellingErrorText = _("Spelling e&rrors") - self.spellingErrorsCheckBox=docInfoGroup.addItem(wx.CheckBox(self,label=spellingErrorText)) + self.spellingErrorsCheckBox = docInfoGroup.addItem(wx.CheckBox(docInfoBox, label=spellingErrorText)) self.spellingErrorsCheckBox.SetValue(config.conf["documentFormatting"]["reportSpellingErrors"]) # Translators: This is the label for a group of document formatting options in the # document formatting settings panel pageAndSpaceGroupText = _("Pages and spacing") - pageAndSpaceGroup = guiHelper.BoxSizerHelper(self, sizer=wx.StaticBoxSizer(wx.StaticBox(self, label=pageAndSpaceGroupText), wx.VERTICAL)) + pageAndSpaceSizer = wx.StaticBoxSizer(wx.VERTICAL, self, label=pageAndSpaceGroupText) + pageAndSpaceBox = pageAndSpaceSizer.GetStaticBox() + pageAndSpaceGroup = guiHelper.BoxSizerHelper(self, sizer=pageAndSpaceSizer) sHelper.addItem(pageAndSpaceGroup) # Translators: This is the label for a checkbox in the # document formatting settings panel. pageText = _("&Pages") - self.pageCheckBox=pageAndSpaceGroup.addItem(wx.CheckBox(self,label=pageText)) + self.pageCheckBox = pageAndSpaceGroup.addItem(wx.CheckBox(pageAndSpaceBox, label=pageText)) self.pageCheckBox.SetValue(config.conf["documentFormatting"]["reportPage"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. lineText = _("Line &numbers") - self.lineNumberCheckBox=pageAndSpaceGroup.addItem(wx.CheckBox(self,label=lineText)) + self.lineNumberCheckBox = pageAndSpaceGroup.addItem(wx.CheckBox(pageAndSpaceBox, label=lineText)) self.lineNumberCheckBox.SetValue(config.conf["documentFormatting"]["reportLineNumber"]) # Translators: This is the label for a combobox controlling the reporting of line indentation in the @@ -2242,40 +2254,46 @@ def makeSettings(self, settingsSizer): # Translators: This message is presented in the document formatting settings panelue # If this option is selected, NVDA will report paragraph indentation if available. paragraphIndentationText = _("&Paragraph indentation") - self.paragraphIndentationCheckBox=pageAndSpaceGroup.addItem(wx.CheckBox(self,label=paragraphIndentationText)) + _paragraphIndentationCheckBox = wx.CheckBox(pageAndSpaceBox, label=paragraphIndentationText) + self.paragraphIndentationCheckBox = pageAndSpaceGroup.addItem(_paragraphIndentationCheckBox) self.paragraphIndentationCheckBox.SetValue(config.conf["documentFormatting"]["reportParagraphIndentation"]) # Translators: This message is presented in the document formatting settings panelue # If this option is selected, NVDA will report line spacing if available. lineSpacingText=_("&Line spacing") - self.lineSpacingCheckBox=pageAndSpaceGroup.addItem(wx.CheckBox(self,label=lineSpacingText)) + _lineSpacingCheckBox = wx.CheckBox(pageAndSpaceBox, label=lineSpacingText) + self.lineSpacingCheckBox = pageAndSpaceGroup.addItem(_lineSpacingCheckBox) self.lineSpacingCheckBox.SetValue(config.conf["documentFormatting"]["reportLineSpacing"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. alignmentText = _("&Alignment") - self.alignmentCheckBox=pageAndSpaceGroup.addItem(wx.CheckBox(self,label=alignmentText)) + self.alignmentCheckBox = pageAndSpaceGroup.addItem(wx.CheckBox(pageAndSpaceBox, label=alignmentText)) self.alignmentCheckBox.SetValue(config.conf["documentFormatting"]["reportAlignment"]) # Translators: This is the label for a group of document formatting options in the # document formatting settings panel tablesGroupText = _("Table information") - tablesGroup = guiHelper.BoxSizerHelper(self, sizer=wx.StaticBoxSizer(wx.StaticBox(self, label=tablesGroupText), wx.VERTICAL)) + tablesGroupSizer = wx.StaticBoxSizer(wx.VERTICAL, self, label=tablesGroupText) + tablesGroupBox = tablesGroupSizer.GetStaticBox() + tablesGroup = guiHelper.BoxSizerHelper(self, sizer=tablesGroupSizer) sHelper.addItem(tablesGroup) # Translators: This is the label for a checkbox in the # document formatting settings panel. - self.tablesCheckBox=tablesGroup.addItem(wx.CheckBox(self,label=_("&Tables"))) + self.tablesCheckBox = tablesGroup.addItem(wx.CheckBox(tablesGroupBox, label=_("&Tables"))) self.tablesCheckBox.SetValue(config.conf["documentFormatting"]["reportTables"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. - self.tableHeadersCheckBox=tablesGroup.addItem(wx.CheckBox(self,label=_("Row/column h&eaders"))) + _tableHeadersCheckBox = wx.CheckBox(tablesGroupBox, label=_("Row/column h&eaders")) + self.tableHeadersCheckBox = tablesGroup.addItem(_tableHeadersCheckBox) self.tableHeadersCheckBox.SetValue(config.conf["documentFormatting"]["reportTableHeaders"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. - self.tableCellCoordsCheckBox=tablesGroup.addItem(wx.CheckBox(self,label=_("Cell c&oordinates"))) + _tableCellCoordsCheckBox = wx.CheckBox(tablesGroupBox, label=_("Cell c&oordinates")) + self.tableCellCoordsCheckBox = tablesGroup.addItem(_tableCellCoordsCheckBox) self.tableCellCoordsCheckBox.SetValue(config.conf["documentFormatting"]["reportTableCellCoords"]) borderChoices=[ @@ -2307,65 +2325,71 @@ def makeSettings(self, settingsSizer): # Translators: This is the label for a group of document formatting options in the # document formatting settings panel elementsGroupText = _("Elements") - elementsGroup = guiHelper.BoxSizerHelper(self, sizer=wx.StaticBoxSizer(wx.StaticBox(self, label=elementsGroupText), wx.VERTICAL)) + elementsGroupSizer = wx.StaticBoxSizer(wx.VERTICAL, self, label=elementsGroupText) + elementsGroupBox = elementsGroupSizer.GetStaticBox() + elementsGroup = guiHelper.BoxSizerHelper(self, sizer=elementsGroupSizer) sHelper.addItem(elementsGroup, flag=wx.EXPAND, proportion=1) # Translators: This is the label for a checkbox in the # document formatting settings panel. - self.headingsCheckBox=elementsGroup.addItem(wx.CheckBox(self,label=_("&Headings"))) + self.headingsCheckBox = elementsGroup.addItem(wx.CheckBox(elementsGroupBox, label=_("&Headings"))) self.headingsCheckBox.SetValue(config.conf["documentFormatting"]["reportHeadings"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. - self.linksCheckBox=elementsGroup.addItem(wx.CheckBox(self,label=_("Lin&ks"))) + self.linksCheckBox = elementsGroup.addItem(wx.CheckBox(elementsGroupBox, label=_("Lin&ks"))) self.linksCheckBox.SetValue(config.conf["documentFormatting"]["reportLinks"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. - self.graphicsCheckBox = elementsGroup.addItem(wx.CheckBox(self, label=_("&Graphics"))) + self.graphicsCheckBox = elementsGroup.addItem(wx.CheckBox(elementsGroupBox, label=_("&Graphics"))) self.graphicsCheckBox.SetValue(config.conf["documentFormatting"]["reportGraphics"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. - self.listsCheckBox=elementsGroup.addItem(wx.CheckBox(self,label=_("&Lists"))) + self.listsCheckBox = elementsGroup.addItem(wx.CheckBox(elementsGroupBox, label=_("&Lists"))) self.listsCheckBox.SetValue(config.conf["documentFormatting"]["reportLists"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. - self.blockQuotesCheckBox=elementsGroup.addItem(wx.CheckBox(self,label=_("Block "es"))) + _blockQuotesCheckBox = wx.CheckBox(elementsGroupBox, label=_("Block "es")) + self.blockQuotesCheckBox = elementsGroup.addItem(_blockQuotesCheckBox) self.blockQuotesCheckBox.SetValue(config.conf["documentFormatting"]["reportBlockQuotes"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. groupingsText = _("&Groupings") - self.groupingsCheckBox = elementsGroup.addItem(wx.CheckBox(self, label=groupingsText)) + self.groupingsCheckBox = elementsGroup.addItem(wx.CheckBox(elementsGroupBox, label=groupingsText)) self.groupingsCheckBox.SetValue(config.conf["documentFormatting"]["reportGroupings"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. landmarksText = _("Lan&dmarks and regions") - self.landmarksCheckBox = elementsGroup.addItem(wx.CheckBox(self, label=landmarksText)) + self.landmarksCheckBox = elementsGroup.addItem(wx.CheckBox(elementsGroupBox, label=landmarksText)) self.landmarksCheckBox.SetValue(config.conf["documentFormatting"]["reportLandmarks"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. - self.articlesCheckBox = elementsGroup.addItem(wx.CheckBox(self, label=_("Arti&cles"))) + self.articlesCheckBox = elementsGroup.addItem(wx.CheckBox(elementsGroupBox, label=_("Arti&cles"))) self.articlesCheckBox.SetValue(config.conf["documentFormatting"]["reportArticles"]) # Translators: This is the label for a checkbox in the # document formatting settings panel. - self.framesCheckBox=elementsGroup.addItem(wx.CheckBox(self,label=_("Fra&mes"))) + self.framesCheckBox = elementsGroup.addItem(wx.CheckBox(elementsGroupBox, label=_("Fra&mes"))) self.framesCheckBox.Value=config.conf["documentFormatting"]["reportFrames"] # Translators: This is the label for a checkbox in the # document formatting settings panel. - self.clickableCheckBox=elementsGroup.addItem(wx.CheckBox(self,label=_("&Clickable"))) + self.clickableCheckBox = elementsGroup.addItem(wx.CheckBox(elementsGroupBox, label=_("&Clickable"))) self.clickableCheckBox.Value=config.conf["documentFormatting"]["reportClickable"] # Translators: This is the label for a checkbox in the # document formatting settings panel. detectFormatAfterCursorText = _("Report formatting chan&ges after the cursor (can cause a lag)") - self.detectFormatAfterCursorCheckBox=wx.CheckBox(self, label=detectFormatAfterCursorText) + self.detectFormatAfterCursorCheckBox = wx.CheckBox( + elementsGroupBox, + label=detectFormatAfterCursorText + ) self.bindHelpEvent( "DocumentFormattingDetectFormatAfterCursor", self.detectFormatAfterCursorCheckBox @@ -2485,16 +2509,15 @@ def __init__(self, parent): # Translators: This is the label for a group of advanced options in the # Advanced settings panel groupText = _("NVDA Development") - devGroup = guiHelper.BoxSizerHelper( - parent=self, - sizer=wx.StaticBoxSizer(parent=self, label=groupText, orient=wx.VERTICAL) - ) + devGroupSizer = wx.StaticBoxSizer(wx.VERTICAL, self, label=groupText) + devGroupBox = devGroupSizer.GetStaticBox() + devGroup = guiHelper.BoxSizerHelper(self, sizer=devGroupSizer) sHelper.addItem(devGroup) # Translators: This is the label for a checkbox in the # Advanced settings panel. label = _("Enable loading custom code from Developer Scratchpad directory") - self.scratchpadCheckBox=devGroup.addItem(wx.CheckBox(self, label=label)) + self.scratchpadCheckBox = devGroup.addItem(wx.CheckBox(devGroupBox, label=label)) self.bindHelpEvent("AdvancedSettingsEnableScratchpad", self.scratchpadCheckBox) self.scratchpadCheckBox.SetValue(config.conf["development"]["enableScratchpadDir"]) self.scratchpadCheckBox.defaultValue = self._getDefaultValue(["development", "enableScratchpadDir"]) @@ -2507,7 +2530,7 @@ def __init__(self, parent): # Translators: the label for a button in the Advanced settings category label=_("Open developer scratchpad directory") - self.openScratchpadButton=devGroup.addItem(wx.Button(self, label=label)) + self.openScratchpadButton = devGroup.addItem(wx.Button(devGroupBox, label=label)) self.bindHelpEvent("AdvancedSettingsOpenScratchpadDir", self.openScratchpadButton) self.openScratchpadButton.Enable(config.conf["development"]["enableScratchpadDir"]) self.openScratchpadButton.Bind(wx.EVT_BUTTON,self.onOpenScratchpadDir) @@ -2517,16 +2540,15 @@ def __init__(self, parent): # Translators: This is the label for a group of advanced options in the # Advanced settings panel label = _("Microsoft UI Automation") - UIAGroup = guiHelper.BoxSizerHelper( - parent=self, - sizer=wx.StaticBoxSizer(parent=self, label=label, orient=wx.VERTICAL) - ) + UIASizer = wx.StaticBoxSizer(wx.VERTICAL, self, label=label) + UIABox = UIASizer.GetStaticBox() + UIAGroup = guiHelper.BoxSizerHelper(self, sizer=UIASizer) sHelper.addItem(UIAGroup) # Translators: This is the label for a checkbox in the # Advanced settings panel. label = _("Enable &selective registration for UI Automation events and property changes") - self.selectiveUIAEventRegistrationCheckBox = UIAGroup.addItem(wx.CheckBox(self, label=label)) + self.selectiveUIAEventRegistrationCheckBox = UIAGroup.addItem(wx.CheckBox(UIABox, label=label)) self.bindHelpEvent( "AdvancedSettingsSelectiveUIAEventRegistration", self.selectiveUIAEventRegistrationCheckBox @@ -2539,7 +2561,7 @@ def __init__(self, parent): # Translators: This is the label for a checkbox in the # Advanced settings panel. label = _("Use UI Automation to access Microsoft &Word document controls when available") - self.UIAInMSWordCheckBox=UIAGroup.addItem(wx.CheckBox(self, label=label)) + self.UIAInMSWordCheckBox = UIAGroup.addItem(wx.CheckBox(UIABox, label=label)) self.bindHelpEvent("AdvancedSettingsUseUiaForWord", self.UIAInMSWordCheckBox) self.UIAInMSWordCheckBox.SetValue(config.conf["UIA"]["useInMSWordWhenAvailable"]) self.UIAInMSWordCheckBox.defaultValue = self._getDefaultValue(["UIA", "useInMSWordWhenAvailable"]) @@ -2548,7 +2570,7 @@ def __init__(self, parent): # Advanced settings panel. label = _("Use UI Automation to access the Windows C&onsole when available") consoleUIADevMap = True if config.conf['UIA']['winConsoleImplementation'] == 'UIA' else False - self.ConsoleUIACheckBox = UIAGroup.addItem(wx.CheckBox(self, label=label)) + self.ConsoleUIACheckBox = UIAGroup.addItem(wx.CheckBox(UIABox, label=label)) self.bindHelpEvent("AdvancedSettingsConsoleUIA", self.ConsoleUIACheckBox) self.ConsoleUIACheckBox.SetValue(consoleUIADevMap) self.ConsoleUIACheckBox.defaultValue = self._getDefaultValue(["UIA", "winConsoleImplementation"]) @@ -2556,7 +2578,7 @@ def __init__(self, parent): # Translators: This is the label for a checkbox in the # Advanced settings panel. label = _("Speak &passwords in UIA consoles (may improve performance)") - self.winConsoleSpeakPasswordsCheckBox = UIAGroup.addItem(wx.CheckBox(self, label=label)) + self.winConsoleSpeakPasswordsCheckBox = UIAGroup.addItem(wx.CheckBox(UIABox, label=label)) self.bindHelpEvent("AdvancedSettingsWinConsoleSpeakPasswords", self.winConsoleSpeakPasswordsCheckBox) self.winConsoleSpeakPasswordsCheckBox.SetValue(config.conf["terminals"]["speakPasswords"]) self.winConsoleSpeakPasswordsCheckBox.defaultValue = self._getDefaultValue(["terminals", "speakPasswords"]) @@ -2586,15 +2608,14 @@ def __init__(self, parent): # Translators: This is the label for a group of advanced options in the # Advanced settings panel label = _("Terminal programs") - terminalsGroup = guiHelper.BoxSizerHelper( - parent=self, - sizer=wx.StaticBoxSizer(parent=self, label=label, orient=wx.VERTICAL) - ) + terminalsSizer = wx.StaticBoxSizer(wx.VERTICAL, self, label=label) + terminalsBox = terminalsSizer.GetStaticBox() + terminalsGroup = guiHelper.BoxSizerHelper(self, sizer=terminalsSizer) sHelper.addItem(terminalsGroup) # Translators: This is the label for a checkbox in the # Advanced settings panel. label = _("Use the new t&yped character support in Windows Console when available") - self.keyboardSupportInLegacyCheckBox=terminalsGroup.addItem(wx.CheckBox(self, label=label)) + self.keyboardSupportInLegacyCheckBox = terminalsGroup.addItem(wx.CheckBox(terminalsBox, label=label)) self.bindHelpEvent("AdvancedSettingsKeyboardSupportInLegacy", self.keyboardSupportInLegacyCheckBox) self.keyboardSupportInLegacyCheckBox.SetValue(config.conf["terminals"]["keyboardSupportInLegacy"]) self.keyboardSupportInLegacyCheckBox.defaultValue = self._getDefaultValue(["terminals", "keyboardSupportInLegacy"]) @@ -2639,10 +2660,8 @@ def __init__(self, parent): # Translators: This is the label for a group of advanced options in the # Advanced settings panel label = _("Speech") - speechGroup = guiHelper.BoxSizerHelper( - parent=self, - sizer=wx.StaticBoxSizer(parent=self, label=label, orient=wx.VERTICAL) - ) + speechSizer = wx.StaticBoxSizer(wx.VERTICAL, self, label=label) + speechGroup = guiHelper.BoxSizerHelper(speechSizer, sizer=speechSizer) sHelper.addItem(speechGroup) expiredFocusSpeechChoices = [ @@ -2675,10 +2694,8 @@ def __init__(self, parent): # Translators: This is the label for a group of advanced options in the # Advanced settings panel label = _("Editable Text") - editableTextGroup = guiHelper.BoxSizerHelper( - self, - sizer=wx.StaticBoxSizer(parent=self, label=label, orient=wx.VERTICAL) - ) + editableSizer = wx.StaticBoxSizer(wx.VERTICAL, self, label=label) + editableTextGroup = guiHelper.BoxSizerHelper(editableSizer, sizer=editableSizer) sHelper.addItem(editableTextGroup) # Translators: This is the label for a numeric control in the @@ -2697,10 +2714,8 @@ def __init__(self, parent): # Translators: This is the label for a group of advanced options in the # Advanced settings panel label = _("Debug logging") - debugLogGroup = guiHelper.BoxSizerHelper( - self, - sizer=wx.StaticBoxSizer(parent=self, label=label, orient=wx.VERTICAL) - ) + debugLogSizer = wx.StaticBoxSizer(wx.VERTICAL, self, label=label) + debugLogGroup = guiHelper.BoxSizerHelper(self, sizer=debugLogSizer) sHelper.addItem(debugLogGroup) self.logCategories=[ @@ -2824,12 +2839,10 @@ def makeSettings(self, settingsSizer): :type settingsSizer: wx.BoxSizer """ sHelper = guiHelper.BoxSizerHelper(self, sizer=settingsSizer) - warningGroup = guiHelper.BoxSizerHelper( - self, - sizer=wx.StaticBoxSizer(wx.StaticBox(self), wx.VERTICAL) - ) - sHelper.addItem(warningGroup) + warningSizer = wx.StaticBoxSizer(wx.VERTICAL, self) + warningGroup = guiHelper.BoxSizerHelper(self, sizer=warningSizer) warningBox = warningGroup.sizer.GetStaticBox() # type: wx.StaticBox + sHelper.addItem(warningGroup) warningText = wx.StaticText(warningBox, label=self.warningHeader) warningText.SetFont(wx.Font(18, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.BOLD)) @@ -2851,7 +2864,7 @@ def makeSettings(self, settingsSizer): restoreDefaultsButton = warningGroup.addItem( # Translators: This is the label for a button in the Advanced settings panel - wx.Button(self, label=_("Restore defaults")) + wx.Button(warningBox, label=_("Restore defaults")) ) self.bindHelpEvent("AdvancedSettingsRestoringDefaults", restoreDefaultsButton) restoreDefaultsButton.Bind(wx.EVT_BUTTON, lambda evt: self.advancedControls.restoreToDefaults()) @@ -3102,15 +3115,20 @@ def makeSettings(self, settingsSizer): # Translators: A label for the braille display on the braille panel. displayLabel = _("Braille &display") - displayBox = wx.StaticBox(self, label=displayLabel) - displayGroup = guiHelper.BoxSizerHelper(self, sizer=wx.StaticBoxSizer(displayBox, wx.HORIZONTAL)) + displaySizer = wx.StaticBoxSizer(wx.HORIZONTAL, self, label=displayLabel) + displayBox = displaySizer.GetStaticBox() + displayGroup = guiHelper.BoxSizerHelper(self, sizer=displaySizer) settingsSizerHelper.addItem(displayGroup) - self.displayNameCtrl = ExpandoTextCtrl(self, size=(self.scaleSize(250), -1), style=wx.TE_READONLY) + self.displayNameCtrl = ExpandoTextCtrl( + displayBox, + size=(self.scaleSize(250), -1), + style=wx.TE_READONLY + ) self.bindHelpEvent("BrailleSettingsChange", self.displayNameCtrl) self.updateCurrentDisplay() # Translators: This is the label for the button used to change braille display, # it appears in the context of a braille display group on the braille settings panel. - changeDisplayBtn = wx.Button(self, label=_("C&hange...")) + changeDisplayBtn = wx.Button(displayBox, label=_("C&hange...")) self.bindHelpEvent("BrailleSettingsChange", changeDisplayBtn) displayGroup.addItem( guiHelper.associateElements( @@ -3712,7 +3730,7 @@ def makeSettings(self, settingsSizer: wx.BoxSizer): for providerInfo in vision.handler.getProviderList(reloadFromSystem=True): providerSizer = self.settingsSizerHelper.addItem( - wx.StaticBoxSizer(wx.StaticBox(self, label=providerInfo.displayName), wx.VERTICAL), + wx.StaticBoxSizer(wx.VERTICAL, self, label=providerInfo.displayName), flag=wx.EXPAND ) if len(self.providerPanelInstances) > 0: @@ -4089,14 +4107,9 @@ def makeSettings(self, settingsSizer): # Translators: The label for the group of controls in symbol pronunciation dialog to change the pronunciation of a symbol. changeSymbolText = _("Change selected symbol") - changeSymbolHelper = sHelper.addItem(guiHelper.BoxSizerHelper( - parent=self, - sizer=wx.StaticBoxSizer( - parent=self, - label=changeSymbolText, - orient=wx.VERTICAL, - ) - )) + changeSymbolSizer = wx.StaticBoxSizer(wx.VERTICAL, self, label=changeSymbolText) + changeSymbolGroup = guiHelper.BoxSizerHelper(self, sizer=changeSymbolSizer) + changeSymbolHelper = sHelper.addItem(changeSymbolGroup) # Used to ensure that event handlers call Skip(). Not calling skip can cause focus problems for controls. More # generally the advice on the wx documentation is: "In general, it is recommended to skip all non-command events diff --git a/source/languageHandler.py b/source/languageHandler.py index b134ea0373f..c3ab3dc4ab0 100644 --- a/source/languageHandler.py +++ b/source/languageHandler.py @@ -178,7 +178,8 @@ def setLanguage(lang): # #9207: Python 3.8 adds gettext.pgettext, so add it to the built-in namespace. trans.install(names=["pgettext"]) -def getLanguage(): + +def getLanguage() -> str: return curLang def normalizeLanguage(lang):