From 3e9b4b953baee5d841b9d9d5a381e2e28c059ee6 Mon Sep 17 00:00:00 2001 From: buddsean Date: Thu, 4 Mar 2021 17:27:36 +1100 Subject: [PATCH 1/4] Create and implement forced LTR StaticBoxSizer --- source/gui/__init__.py | 4 ++-- source/gui/configProfiles.py | 2 +- source/gui/guiHelper.py | 10 ++++++++++ source/gui/installerGui.py | 5 +++-- source/gui/settingsDialogs.py | 32 ++++++++++++++++---------------- 5 files changed, 32 insertions(+), 21 deletions(-) diff --git a/source/gui/__init__.py b/source/gui/__init__.py index 7a4e46e7851..74e7d53af51 100644 --- a/source/gui/__init__.py +++ b/source/gui/__init__.py @@ -710,7 +710,7 @@ 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( + optionsSizer = guiHelper.LTRStaticBoxSizer( wx.StaticBox( self, # Translators: The label for a group box containing the NVDA welcome dialog options. @@ -795,7 +795,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.StaticBox(self, label=groupLabel), wx.VERTICAL)) 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..47e9a20a09b 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.StaticBox(self), wx.HORIZONTAL) profilesListGroupContents = wx.BoxSizer(wx.HORIZONTAL) #contains the profile list and activation button in vertical arrangement. diff --git a/source/gui/guiHelper.py b/source/gui/guiHelper.py index b33edad2875..11c544cc6b9 100644 --- a/source/gui/guiHelper.py +++ b/source/gui/guiHelper.py @@ -367,3 +367,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_LeftToRight) diff --git a/source/gui/installerGui.py b/source/gui/installerGui.py index 8c7fd3e6377..db7169edc3e 100644 --- a/source/gui/installerGui.py +++ b/source/gui/installerGui.py @@ -175,7 +175,7 @@ def __init__(self, parent, isUpdate): self.bindHelpEvent("InstallWithIncompatibleAddons", self.confirmationCheckbox) self.confirmationCheckbox.SetFocus() - optionsSizer = guiHelper.BoxSizerHelper(self, sizer=sHelper.addItem(wx.StaticBoxSizer( + optionsSizer = guiHelper.BoxSizerHelper(self, sizer=sHelper.addItem(guiHelper.LTRStaticBoxSizer( wx.StaticBox( self, # Translators: The label for a group box containing the NVDA installation dialog options. @@ -349,7 +349,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))) + boxSizer = guiHelper.LTRStaticBoxSizer(wx.StaticBox(self, label=directoryGroupText), wx.VERTICAL) + groupHelper = sHelper.addItem(gui.guiHelper.BoxSizerHelper(self, sizer=boxSizer)) # 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 f3216b55b24..4de21c9439f 100644 --- a/source/gui/settingsDialogs.py +++ b/source/gui/settingsDialogs.py @@ -910,7 +910,7 @@ def makeSettings(self, 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)) + synthGroup = guiHelper.BoxSizerHelper(self, sizer=guiHelper.LTRStaticBoxSizer(synthBox, wx.HORIZONTAL)) settingsSizerHelper.addItem(synthGroup) # Use a ExpandoTextCtrl because even when readonly it accepts focus from keyboard, which @@ -2121,7 +2121,7 @@ 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)) + fontGroup = guiHelper.BoxSizerHelper(self, sizer=guiHelper.LTRStaticBoxSizer(wx.StaticBox(self, label=fontGroupText), wx.VERTICAL)) sHelper.addItem(fontGroup) # Translators: This is the label for a checkbox in the @@ -2183,7 +2183,7 @@ 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)) + docInfoGroup = guiHelper.BoxSizerHelper(self, sizer=guiHelper.LTRStaticBoxSizer(wx.StaticBox(self, label=documentInfoGroupText), wx.VERTICAL)) sHelper.addItem(docInfoGroup) # Translators: This is the label for a checkbox in the @@ -2207,7 +2207,7 @@ 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)) + pageAndSpaceGroup = guiHelper.BoxSizerHelper(self, sizer=guiHelper.LTRStaticBoxSizer(wx.StaticBox(self, label=pageAndSpaceGroupText), wx.VERTICAL)) sHelper.addItem(pageAndSpaceGroup) # Translators: This is the label for a checkbox in the @@ -2265,7 +2265,7 @@ 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)) + tablesGroup = guiHelper.BoxSizerHelper(self, sizer=guiHelper.LTRStaticBoxSizer(wx.StaticBox(self, label=tablesGroupText), wx.VERTICAL)) sHelper.addItem(tablesGroup) # Translators: This is the label for a checkbox in the @@ -2312,7 +2312,7 @@ 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)) + elementsGroup = guiHelper.BoxSizerHelper(self, sizer=guiHelper.LTRStaticBoxSizer(wx.StaticBox(self, label=elementsGroupText), wx.VERTICAL)) sHelper.addItem(elementsGroup, flag=wx.EXPAND, proportion=1) # Translators: This is the label for a checkbox in the @@ -2492,7 +2492,7 @@ def __init__(self, parent): groupText = _("NVDA Development") devGroup = guiHelper.BoxSizerHelper( parent=self, - sizer=wx.StaticBoxSizer(parent=self, label=groupText, orient=wx.VERTICAL) + sizer=guiHelper.LTRStaticBoxSizer(parent=self, label=groupText, orient=wx.VERTICAL) ) sHelper.addItem(devGroup) @@ -2524,7 +2524,7 @@ def __init__(self, parent): label = _("Microsoft UI Automation") UIAGroup = guiHelper.BoxSizerHelper( parent=self, - sizer=wx.StaticBoxSizer(parent=self, label=label, orient=wx.VERTICAL) + sizer=guiHelper.LTRStaticBoxSizer(parent=self, label=label, orient=wx.VERTICAL) ) sHelper.addItem(UIAGroup) @@ -2593,7 +2593,7 @@ def __init__(self, parent): label = _("Terminal programs") terminalsGroup = guiHelper.BoxSizerHelper( parent=self, - sizer=wx.StaticBoxSizer(parent=self, label=label, orient=wx.VERTICAL) + sizer=guiHelper.LTRStaticBoxSizer(parent=self, label=label, orient=wx.VERTICAL) ) sHelper.addItem(terminalsGroup) # Translators: This is the label for a checkbox in the @@ -2646,7 +2646,7 @@ def __init__(self, parent): label = _("Speech") speechGroup = guiHelper.BoxSizerHelper( parent=self, - sizer=wx.StaticBoxSizer(parent=self, label=label, orient=wx.VERTICAL) + sizer=guiHelper.LTRStaticBoxSizer(parent=self, label=label, orient=wx.VERTICAL) ) sHelper.addItem(speechGroup) @@ -2682,7 +2682,7 @@ def __init__(self, parent): label = _("Editable Text") editableTextGroup = guiHelper.BoxSizerHelper( self, - sizer=wx.StaticBoxSizer(parent=self, label=label, orient=wx.VERTICAL) + sizer=guiHelper.LTRStaticBoxSizer(parent=self, label=label, orient=wx.VERTICAL) ) sHelper.addItem(editableTextGroup) @@ -2704,7 +2704,7 @@ def __init__(self, parent): label = _("Debug logging") debugLogGroup = guiHelper.BoxSizerHelper( self, - sizer=wx.StaticBoxSizer(parent=self, label=label, orient=wx.VERTICAL) + sizer=guiHelper.LTRStaticBoxSizer(parent=self, label=label, orient=wx.VERTICAL) ) sHelper.addItem(debugLogGroup) @@ -2831,7 +2831,7 @@ def makeSettings(self, settingsSizer): sHelper = guiHelper.BoxSizerHelper(self, sizer=settingsSizer) warningGroup = guiHelper.BoxSizerHelper( self, - sizer=wx.StaticBoxSizer(wx.StaticBox(self), wx.VERTICAL) + sizer=guiHelper.LTRStaticBoxSizer(wx.StaticBox(self), wx.VERTICAL) ) sHelper.addItem(warningGroup) warningBox = warningGroup.sizer.GetStaticBox() # type: wx.StaticBox @@ -3108,7 +3108,7 @@ def makeSettings(self, settingsSizer): displayLabel = _("Braille &display") displayBox = wx.StaticBox(self, label=displayLabel) - displayGroup = guiHelper.BoxSizerHelper(self, sizer=wx.StaticBoxSizer(displayBox, wx.HORIZONTAL)) + displayGroup = guiHelper.BoxSizerHelper(self, sizer=guiHelper.LTRStaticBoxSizer(displayBox, wx.HORIZONTAL)) settingsSizerHelper.addItem(displayGroup) self.displayNameCtrl = ExpandoTextCtrl(self, size=(self.scaleSize(250), -1), style=wx.TE_READONLY) self.bindHelpEvent("BrailleSettingsChange", self.displayNameCtrl) @@ -3717,7 +3717,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.StaticBox(self, label=providerInfo.displayName), wx.VERTICAL), flag=wx.EXPAND ) if len(self.providerPanelInstances) > 0: @@ -4096,7 +4096,7 @@ def makeSettings(self, settingsSizer): changeSymbolText = _("Change selected symbol") changeSymbolHelper = sHelper.addItem(guiHelper.BoxSizerHelper( parent=self, - sizer=wx.StaticBoxSizer( + sizer=guiHelper.LTRStaticBoxSizer( parent=self, label=changeSymbolText, orient=wx.VERTICAL, From 1c7381ce92a8e0b24a119ab797671e9c2a8bd759 Mon Sep 17 00:00:00 2001 From: buddsean Date: Fri, 5 Mar 2021 10:46:46 +1100 Subject: [PATCH 2/4] standardize LTRStaticBoxSizer usage --- source/gui/__init__.py | 13 ++---- source/gui/configProfiles.py | 2 +- source/gui/installerGui.py | 16 +++---- source/gui/settingsDialogs.py | 78 ++++++++++++++--------------------- 4 files changed, 43 insertions(+), 66 deletions(-) diff --git a/source/gui/__init__.py b/source/gui/__init__.py index 74e7d53af51..5d9d0d7f553 100644 --- a/source/gui/__init__.py +++ b/source/gui/__init__.py @@ -710,14 +710,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 = guiHelper.LTRStaticBoxSizer( - 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:") @@ -795,7 +790,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(guiHelper.LTRStaticBoxSizer(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 47e9a20a09b..1ad1c52418c 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 = guiHelper.LTRStaticBoxSizer(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. diff --git a/source/gui/installerGui.py b/source/gui/installerGui.py index db7169edc3e..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(guiHelper.LTRStaticBoxSizer( - 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,8 +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:") - boxSizer = guiHelper.LTRStaticBoxSizer(wx.StaticBox(self, label=directoryGroupText), wx.VERTICAL) - groupHelper = sHelper.addItem(gui.guiHelper.BoxSizerHelper(self, sizer=boxSizer)) + 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 4de21c9439f..e5dfad5ef68 100644 --- a/source/gui/settingsDialogs.py +++ b/source/gui/settingsDialogs.py @@ -909,8 +909,8 @@ 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=guiHelper.LTRStaticBoxSizer(synthBox, wx.HORIZONTAL)) + synthBoxSizer = guiHelper.LTRStaticBoxSizer(wx.HORIZONTAL, self, label=synthLabel) + synthGroup = guiHelper.BoxSizerHelper(self, sizer=synthBoxSizer) settingsSizerHelper.addItem(synthGroup) # Use a ExpandoTextCtrl because even when readonly it accepts focus from keyboard, which @@ -2121,7 +2121,8 @@ 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=guiHelper.LTRStaticBoxSizer(wx.StaticBox(self, label=fontGroupText), wx.VERTICAL)) + fontGroupSizer = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=fontGroupText) + fontGroup = guiHelper.BoxSizerHelper(self, sizer=fontGroupSizer) sHelper.addItem(fontGroup) # Translators: This is the label for a checkbox in the @@ -2183,7 +2184,8 @@ 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=guiHelper.LTRStaticBoxSizer(wx.StaticBox(self, label=documentInfoGroupText), wx.VERTICAL)) + docInfoSizer = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=documentInfoGroupText) + docInfoGroup = guiHelper.BoxSizerHelper(self, sizer=docInfoSizer) sHelper.addItem(docInfoGroup) # Translators: This is the label for a checkbox in the @@ -2207,7 +2209,8 @@ 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=guiHelper.LTRStaticBoxSizer(wx.StaticBox(self, label=pageAndSpaceGroupText), wx.VERTICAL)) + pageAndSpaceSizer = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=pageAndSpaceGroupText) + pageAndSpaceGroup = guiHelper.BoxSizerHelper(self, sizer=pageAndSpaceSizer) sHelper.addItem(pageAndSpaceGroup) # Translators: This is the label for a checkbox in the @@ -2265,7 +2268,8 @@ 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=guiHelper.LTRStaticBoxSizer(wx.StaticBox(self, label=tablesGroupText), wx.VERTICAL)) + tablesGroupSizer = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=tablesGroupText) + tablesGroup = guiHelper.BoxSizerHelper(self, sizer=tablesGroupSizer) sHelper.addItem(tablesGroup) # Translators: This is the label for a checkbox in the @@ -2312,7 +2316,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=guiHelper.LTRStaticBoxSizer(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 @@ -2490,10 +2495,8 @@ 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=guiHelper.LTRStaticBoxSizer(parent=self, label=groupText, orient=wx.VERTICAL) - ) + devGroupSizer = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=groupText) + devGroup = guiHelper.BoxSizerHelper(self, sizer=devGroupSizer) sHelper.addItem(devGroup) # Translators: This is the label for a checkbox in the @@ -2522,10 +2525,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=guiHelper.LTRStaticBoxSizer(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 @@ -2591,10 +2592,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=guiHelper.LTRStaticBoxSizer(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. @@ -2644,10 +2643,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=guiHelper.LTRStaticBoxSizer(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 = [ @@ -2680,10 +2677,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=guiHelper.LTRStaticBoxSizer(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 @@ -2702,10 +2697,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=guiHelper.LTRStaticBoxSizer(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=[ @@ -2829,10 +2822,8 @@ def makeSettings(self, settingsSizer): :type settingsSizer: wx.BoxSizer """ sHelper = guiHelper.BoxSizerHelper(self, sizer=settingsSizer) - warningGroup = guiHelper.BoxSizerHelper( - self, - sizer=guiHelper.LTRStaticBoxSizer(wx.StaticBox(self), wx.VERTICAL) - ) + warningSizer = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self) + warningGroup = guiHelper.BoxSizerHelper(self, sizer=warningSizer) sHelper.addItem(warningGroup) warningBox = warningGroup.sizer.GetStaticBox() # type: wx.StaticBox @@ -3107,8 +3098,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=guiHelper.LTRStaticBoxSizer(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) @@ -3717,7 +3708,7 @@ def makeSettings(self, settingsSizer: wx.BoxSizer): for providerInfo in vision.handler.getProviderList(reloadFromSystem=True): providerSizer = self.settingsSizerHelper.addItem( - guiHelper.LTRStaticBoxSizer(wx.StaticBox(self, label=providerInfo.displayName), wx.VERTICAL), + guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=providerInfo.displayName), flag=wx.EXPAND ) if len(self.providerPanelInstances) > 0: @@ -4094,14 +4085,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=guiHelper.LTRStaticBoxSizer( - 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 From 803fcf187a19a2ae2c17353a6ce139868e038d1a Mon Sep 17 00:00:00 2001 From: buddsean Date: Fri, 5 Mar 2021 10:51:11 +1100 Subject: [PATCH 3/4] standardize LTRStaticBoxSizer usage --- source/gui/settingsDialogs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/gui/settingsDialogs.py b/source/gui/settingsDialogs.py index e5dfad5ef68..9afa70f43ec 100644 --- a/source/gui/settingsDialogs.py +++ b/source/gui/settingsDialogs.py @@ -3098,7 +3098,7 @@ def makeSettings(self, settingsSizer): # Translators: A label for the braille display on the braille panel. displayLabel = _("Braille &display") - displaySizer = guiHelper.LTRStaticBoxSizer(wx.HORIZONTAL, self, label=displayLabel)) + 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) From 200e7bdc6cc1742b1e3b854afdb4813c8ba80a62 Mon Sep 17 00:00:00 2001 From: buddsean Date: Mon, 15 Mar 2021 11:49:55 +1100 Subject: [PATCH 4/4] test wx RTL workaround --- source/gui/configProfiles.py | 2 +- source/gui/guiHelper.py | 7 ++++++- source/gui/settingsDialogs.py | 14 +++++++------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/source/gui/configProfiles.py b/source/gui/configProfiles.py index 1ad1c52418c..6e1295fc898 100644 --- a/source/gui/configProfiles.py +++ b/source/gui/configProfiles.py @@ -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 11c544cc6b9..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) @@ -376,4 +381,4 @@ class LTRStaticBoxSizer(wx.StaticBoxSizer): """ def __init__(self, *args, **kw): super().__init__(*args, **kw) - self.StaticBox.SetLayoutDirection(wx.Layout_LeftToRight) + # self.StaticBox.SetLayoutDirection(wx.Layout_RightToLeft) diff --git a/source/gui/settingsDialogs.py b/source/gui/settingsDialogs.py index c535a23ded1..7c7d622ee71 100644 --- a/source/gui/settingsDialogs.py +++ b/source/gui/settingsDialogs.py @@ -911,7 +911,7 @@ def makeSettings(self, settingsSizer): synthLabel = _("&Synthesizer") synthBoxSizer = guiHelper.LTRStaticBoxSizer(wx.HORIZONTAL, self, label=synthLabel) synthGroup = guiHelper.BoxSizerHelper(self, sizer=synthBoxSizer) - settingsSizerHelper.addItem(synthGroup) + 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 @@ -2118,7 +2118,7 @@ def makeSettings(self, settingsSizer): fontGroupText = _("Font") fontGroupSizer = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=fontGroupText) fontGroup = guiHelper.BoxSizerHelper(self, sizer=fontGroupSizer) - sHelper.addItem(fontGroup) + sHelper.addItem(fontGroupSizer.GetStaticBox()) # Translators: This is the label for a checkbox in the # document formatting settings panel. @@ -2181,7 +2181,7 @@ def makeSettings(self, settingsSizer): documentInfoGroupText = _("Document information") docInfoSizer = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=documentInfoGroupText) docInfoGroup = guiHelper.BoxSizerHelper(self, sizer=docInfoSizer) - sHelper.addItem(docInfoGroup) + sHelper.addItem(docInfoSizer.GetStaticBox()) # Translators: This is the label for a checkbox in the # document formatting settings panel. @@ -2206,7 +2206,7 @@ def makeSettings(self, settingsSizer): pageAndSpaceGroupText = _("Pages and spacing") pageAndSpaceSizer = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=pageAndSpaceGroupText) pageAndSpaceGroup = guiHelper.BoxSizerHelper(self, sizer=pageAndSpaceSizer) - sHelper.addItem(pageAndSpaceGroup) + sHelper.addItem(pageAndSpaceSizer.GetStaticBox()) # Translators: This is the label for a checkbox in the # document formatting settings panel. @@ -2265,7 +2265,7 @@ def makeSettings(self, settingsSizer): tablesGroupText = _("Table information") tablesGroupSizer = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=tablesGroupText) tablesGroup = guiHelper.BoxSizerHelper(self, sizer=tablesGroupSizer) - sHelper.addItem(tablesGroup) + sHelper.addItem(tablesGroupSizer.GetStaticBox()) # Translators: This is the label for a checkbox in the # document formatting settings panel. @@ -2492,7 +2492,7 @@ def __init__(self, parent): groupText = _("NVDA Development") devGroupSizer = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=groupText) devGroup = guiHelper.BoxSizerHelper(self, sizer=devGroupSizer) - sHelper.addItem(devGroup) + sHelper.addItem(devGroupSizer.GetStaticBox()) # Translators: This is the label for a checkbox in the # Advanced settings panel. @@ -2819,8 +2819,8 @@ def makeSettings(self, settingsSizer): sHelper = guiHelper.BoxSizerHelper(self, sizer=settingsSizer) warningSizer = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self) warningGroup = guiHelper.BoxSizerHelper(self, sizer=warningSizer) - sHelper.addItem(warningGroup) 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))