diff --git a/source/gui/__init__.py b/source/gui/__init__.py index 368e537acd5..15b692eaf1a 100644 --- a/source/gui/__init__.py +++ b/source/gui/__init__.py @@ -725,14 +725,9 @@ 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 = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=optionsLabel) sHelper = guiHelper.BoxSizerHelper(self, sizer=optionsSizer) # Translators: The label of a combobox in the Welcome dialog. kbdLabelText = _("&Keyboard layout:") @@ -810,7 +805,7 @@ 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 = sHelper.addItem(guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=groupLabel)) 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..6e1295fc898 100644 --- a/source/gui/configProfiles.py +++ b/source/gui/configProfiles.py @@ -42,7 +42,7 @@ 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 = guiHelper.LTRStaticBoxSizer(wx.HORIZONTAL, self) profilesListGroupContents = wx.BoxSizer(wx.HORIZONTAL) #contains the profile list and activation button in vertical arrangement. @@ -84,7 +84,7 @@ def __init__(self, parent): profilesListGroupContents.Add(buttonHelper.sizer) profilesListGroupSizer.Add(profilesListGroupContents, border=guiHelper.BORDER_FOR_DIALOGS, flag=wx.ALL) - sHelper.addItem(profilesListGroupSizer) + sHelper.addItem(profilesListGroupSizer.GetStaticBox()) # Translators: The label of a button to manage triggers # in the Configuration Profiles dialog. diff --git a/source/gui/guiHelper.py b/source/gui/guiHelper.py index b33edad2875..66ebca026b3 100644 --- a/source/gui/guiHelper.py +++ b/source/gui/guiHelper.py @@ -307,6 +307,11 @@ def addItem(self, item, **keywordArgs): if isinstance(toAdd, (wx.StaticBoxSizer, scrolledpanel.ScrolledPanel)): keywordArgs["flag"] = keywordArgs.get("flag", 0) | wx.EXPAND + if isinstance(toAdd, wx.StaticBoxSizer): + toAdd = toAdd.GetStaticBox() + if isinstance(toAdd, wx.Box): + toAdd.SetContainingSizer(None) + if shouldAddSpacer: self.sizer.AddSpacer(SPACE_BETWEEN_VERTICAL_DIALOG_ITEMS) self.sizer.Add(toAdd, **keywordArgs) @@ -367,3 +372,13 @@ class SIPABCMeta(wx.siplib.wrappertype, ABCMeta): """Meta class to be used for wx subclasses with abstract methods.""" pass + +class LTRStaticBoxSizer(wx.StaticBoxSizer): + """ + An Overridden StaticBoxSizer as the original is buggy for RTL languages + Awaiting bug-fix for issue: https://trac.wxwidgets.org/ticket/19086 + This override has a side effect of left alignment of grouping headers (StaticBox labels) for RTL languages + """ + def __init__(self, *args, **kw): + super().__init__(*args, **kw) + # self.StaticBox.SetLayoutDirection(wx.Layout_RightToLeft) diff --git a/source/gui/installerGui.py b/source/gui/installerGui.py index 8c7fd3e6377..fc8724ea1b6 100644 --- a/source/gui/installerGui.py +++ b/source/gui/installerGui.py @@ -175,14 +175,10 @@ 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(guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=optionsLabel)) + optionsSizer = guiHelper.BoxSizerHelper(self, sizer=optionsHelper) # Translators: The label of a checkbox option in the Install NVDA dialog. startOnLogonText = _("Use NVDA during sign-in") @@ -349,7 +345,8 @@ 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 = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=directoryGroupText) + groupHelper = sHelper.addItem(gui.guiHelper.BoxSizerHelper(self, sizer=groupSizer)) # Translators: The label of a button to browse for a directory. browseText = _("Browse...") # Translators: The title of the dialog presented when browsing for the diff --git a/source/gui/settingsDialogs.py b/source/gui/settingsDialogs.py index 869eed402d0..7c7d622ee71 100644 --- a/source/gui/settingsDialogs.py +++ b/source/gui/settingsDialogs.py @@ -909,9 +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)) - settingsSizerHelper.addItem(synthGroup) + synthBoxSizer = guiHelper.LTRStaticBoxSizer(wx.HORIZONTAL, self, label=synthLabel) + synthGroup = guiHelper.BoxSizerHelper(self, sizer=synthBoxSizer) + settingsSizerHelper.addItem(synthBoxSizer.GetStaticBox()) # Use a ExpandoTextCtrl because even when readonly it accepts focus from keyboard, which # standard readonly TextCtrl does not. ExpandoTextCtrl is a TE_MULTILINE control, however @@ -2116,8 +2116,9 @@ 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)) - sHelper.addItem(fontGroup) + fontGroupSizer = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=fontGroupText) + fontGroup = guiHelper.BoxSizerHelper(self, sizer=fontGroupSizer) + sHelper.addItem(fontGroupSizer.GetStaticBox()) # Translators: This is the label for a checkbox in the # document formatting settings panel. @@ -2178,8 +2179,9 @@ def makeSettings(self, settingsSizer): # 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)) - sHelper.addItem(docInfoGroup) + docInfoSizer = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=documentInfoGroupText) + docInfoGroup = guiHelper.BoxSizerHelper(self, sizer=docInfoSizer) + sHelper.addItem(docInfoSizer.GetStaticBox()) # Translators: This is the label for a checkbox in the # document formatting settings panel. @@ -2202,8 +2204,9 @@ def makeSettings(self, settingsSizer): # 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)) - sHelper.addItem(pageAndSpaceGroup) + pageAndSpaceSizer = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=pageAndSpaceGroupText) + pageAndSpaceGroup = guiHelper.BoxSizerHelper(self, sizer=pageAndSpaceSizer) + sHelper.addItem(pageAndSpaceSizer.GetStaticBox()) # Translators: This is the label for a checkbox in the # document formatting settings panel. @@ -2260,8 +2263,9 @@ def makeSettings(self, settingsSizer): # 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)) - sHelper.addItem(tablesGroup) + tablesGroupSizer = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=tablesGroupText) + tablesGroup = guiHelper.BoxSizerHelper(self, sizer=tablesGroupSizer) + sHelper.addItem(tablesGroupSizer.GetStaticBox()) # Translators: This is the label for a checkbox in the # document formatting settings panel. @@ -2307,7 +2311,8 @@ 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 = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=elementsGroupText) + elementsGroup = guiHelper.BoxSizerHelper(self, sizer=elementsGroupSizer) sHelper.addItem(elementsGroup, flag=wx.EXPAND, proportion=1) # Translators: This is the label for a checkbox in the @@ -2485,11 +2490,9 @@ 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) - ) - sHelper.addItem(devGroup) + devGroupSizer = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=groupText) + devGroup = guiHelper.BoxSizerHelper(self, sizer=devGroupSizer) + sHelper.addItem(devGroupSizer.GetStaticBox()) # Translators: This is the label for a checkbox in the # Advanced settings panel. @@ -2517,10 +2520,8 @@ 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 = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=label) + UIAGroup = guiHelper.BoxSizerHelper(self, sizer=UIASizer) sHelper.addItem(UIAGroup) # Translators: This is the label for a checkbox in the @@ -2586,10 +2587,8 @@ 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 = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=label) + terminalsGroup = guiHelper.BoxSizerHelper(self, sizer=terminalsSizer) sHelper.addItem(terminalsGroup) # Translators: This is the label for a checkbox in the # Advanced settings panel. @@ -2639,10 +2638,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 = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=label) + speechGroup = guiHelper.BoxSizerHelper(self, sizer=speechSizer) sHelper.addItem(speechGroup) expiredFocusSpeechChoices = [ @@ -2675,10 +2672,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 = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=label) + editableTextGroup = guiHelper.BoxSizerHelper(self, sizer=editableSizer) sHelper.addItem(editableTextGroup) # Translators: This is the label for a numeric control in the @@ -2697,10 +2692,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 = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=label) + debugLogGroup = guiHelper.BoxSizerHelper(self, sizer=debugLogSizer) sHelper.addItem(debugLogGroup) self.logCategories=[ @@ -2824,12 +2817,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 = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self) + warningGroup = guiHelper.BoxSizerHelper(self, sizer=warningSizer) warningBox = warningGroup.sizer.GetStaticBox() # type: wx.StaticBox + sHelper.addItem(warningBox) warningText = wx.StaticText(warningBox, label=self.warningHeader) warningText.SetFont(wx.Font(18, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.BOLD)) @@ -3102,8 +3093,8 @@ 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 = guiHelper.LTRStaticBoxSizer(wx.HORIZONTAL, self, label=displayLabel) + displayGroup = guiHelper.BoxSizerHelper(self, sizer=displaySizer) settingsSizerHelper.addItem(displayGroup) self.displayNameCtrl = ExpandoTextCtrl(self, size=(self.scaleSize(250), -1), style=wx.TE_READONLY) self.bindHelpEvent("BrailleSettingsChange", self.displayNameCtrl) @@ -3712,7 +3703,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), + guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=providerInfo.displayName), flag=wx.EXPAND ) if len(self.providerPanelInstances) > 0: @@ -4089,14 +4080,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 = guiHelper.LTRStaticBoxSizer(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