Repository navigation
Fix gui alignment issues #6287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Fix gui alignment issues #6287
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
1e232cf
fix alignment of the exit dialog
feerrenrut 825864f
fix general settings alignments
feerrenrut e13351d
fixed alignment in the synthesizer dialog
feerrenrut 81cd171
fix alignment on voice settings dialog
feerrenrut c3f2a35
fix alignment on keyboard and mouse settings dialogs
feerrenrut fa3384c
fix alignment on braille settings dialogs
feerrenrut 82b7dbf
fix alignment on the object presentation settings dialogs
feerrenrut 1ba26ac
fix alignment on the dictionary dialog
feerrenrut dfacc70
fix alignment on the input gestures dialog
feerrenrut e710892
fix alignment on the configuration profiles dialog
feerrenrut c64f213
fix alignment on the new config profile dialog
feerrenrut 173879f
fix alignment on the profile triggers dialog
feerrenrut 531aaa9
Pull out common gui patterns into a helper module.
feerrenrut 0cb617b
Show symbols on tree view
feerrenrut b3a05c4
fixed up alignment and spacing on the elements list dialog
feerrenrut 4b8ab58
WIP
feerrenrut 17e2c3a
Gui helper is now class based
feerrenrut 899358e
Moved more of the code over to the class based approach
feerrenrut 20c88e0
Updated comments for the guiHelper
feerrenrut 108ee95
Fix some errors and remove 'name' parameter
feerrenrut 8e93c71
Fixed up missed part of gui
feerrenrut a8ca09b
fix alignment on several dialogs
feerrenrut 4b52d5d
Update some remainig dialogs
feerrenrut 86548ae
minor fixes
feerrenrut ac401a8
Review actions for #6287
feerrenrut a262092
Fixed up an out of order comment for #6287
feerrenrut File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix some errors and remove 'name' parameter
Some wx controls were being created using the 'name' parameter. When there is a label this is unnecessary, since the label will describe the controls. It may also be unnecessary when there is sufficient context provided by the dialog itself.
- Loading branch information
commit 108ee95351009c5013fd4368e8f2b4e8b62a5b33
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,36 +104,35 @@ def associateElements( firstElement, secondElement): | |
| wx.StaticText and (wx.ListCtrl or wx.ListBox or wx.TreeCtrl ) - Vertical layout | ||
| wx.Button and wx.CheckBox - Horizontal layout | ||
| """ | ||
| if isinstance(firstElement, ButtonHelper) or isinstance(secondElement, ButtonHelper): | ||
| raise NotImplementedError("AssociateElements has no implementation for ButtonHelper elements") | ||
| if isinstance(firstElement, LabeledControlHelper) or isinstance(secondElement, LabeledControlHelper) | ||
| raise NotImplementedError("AssociateElements as no implementation for LabeledControlHelper elements") | ||
|
|
||
| # staticText and (choice or textCtrl) | ||
| if isinstance(firstElement, wx.StaticText) and isinstance(secondElement, (wx.Choice, wx.TextCtrl)): | ||
| sizer = wx.BoxSizer(wx.HORIZONTAL) | ||
| kwargs = {} | ||
| kwargs.update( {'flag':wx.ALIGN_CENTER_VERTICAL} ) | ||
| else: raise NotImplementedError("firstElement not supported with secondElement type.") | ||
| sizer.Add(firstElement, **kwargs) | ||
| sizer.AddSpacer(SPACE_BETWEEN_ASSOCIATED_CONTROL_HORIZONTAL) | ||
| sizer.Add(secondElement) | ||
| # staticText and (ListCtrl, ListBox or TreeCtrl) | ||
| elif isinstance(firstElement, wx.StaticText) and isinstance(secondElement, (wx.ListCtrl,wx.ListBox,wx.TreeCtrl)): | ||
| sizer = wx.BoxSizer(wx.VERTICAL) | ||
| sizer.Add(firstElement) | ||
| sizer.AddSpacer(SPACE_BETWEEN_ASSOCIATED_CONTROL_VERTICAL) | ||
| sizer.Add(secondElement) | ||
| # button and checkBox | ||
| elif isinstance(firstElement, wx.Button) and isinstance(secondElement, wx.CheckBox): | ||
| sizer = wx.BoxSizer(wx.HORIZONTAL) | ||
| sizer.Add(firstElement) | ||
| sizer.AddSpacer(SPACE_BETWEEN_ASSOCIATED_CONTROL_HORIZONTAL) | ||
| sizer.Add(secondElement, flag=wx.ALIGN_CENTER_VERTICAL) | ||
| else: | ||
| raise NotImplementedError("The firstElement and secondElement argument combination has no implementation") | ||
|
|
||
| return sizer | ||
| if isinstance(firstElement, ButtonHelper) or isinstance(secondElement, ButtonHelper): | ||
| raise NotImplementedError("AssociateElements has no implementation for ButtonHelper elements") | ||
| if isinstance(firstElement, LabeledControlHelper) or isinstance(secondElement, LabeledControlHelper): | ||
| raise NotImplementedError("AssociateElements as no implementation for LabeledControlHelper elements") | ||
|
|
||
| # staticText and (choice or textCtrl) | ||
| if isinstance(firstElement, wx.StaticText) and isinstance(secondElement, (wx.Choice, wx.TextCtrl)): | ||
| sizer = wx.BoxSizer(wx.HORIZONTAL) | ||
| kwargs = {} | ||
| kwargs.update( {'flag':wx.ALIGN_CENTER_VERTICAL} ) | ||
| sizer.Add(firstElement, **kwargs) | ||
| sizer.AddSpacer(SPACE_BETWEEN_ASSOCIATED_CONTROL_HORIZONTAL) | ||
| sizer.Add(secondElement) | ||
| # staticText and (ListCtrl, ListBox or TreeCtrl) | ||
| elif isinstance(firstElement, wx.StaticText) and isinstance(secondElement, (wx.ListCtrl,wx.ListBox,wx.TreeCtrl)): | ||
| sizer = wx.BoxSizer(wx.VERTICAL) | ||
| sizer.Add(firstElement) | ||
| sizer.AddSpacer(SPACE_BETWEEN_ASSOCIATED_CONTROL_VERTICAL) | ||
| sizer.Add(secondElement) | ||
| # button and checkBox | ||
| elif isinstance(firstElement, wx.Button) and isinstance(secondElement, wx.CheckBox): | ||
| sizer = wx.BoxSizer(wx.HORIZONTAL) | ||
| sizer.Add(firstElement) | ||
| sizer.AddSpacer(SPACE_BETWEEN_ASSOCIATED_CONTROL_HORIZONTAL) | ||
| sizer.Add(secondElement, flag=wx.ALIGN_CENTER_VERTICAL) | ||
| else: | ||
| raise NotImplementedError("The firstElement and secondElement argument combination has no implementation") | ||
|
|
||
| return sizer | ||
|
|
||
| class LabeledControlHelper(object): | ||
| """ Represents a Labeled Control. Provides a class to create and hold on to the objects and automatically associate | ||
|
|
@@ -164,13 +163,13 @@ class BoxSizerHelper(object): | |
| """ Used to abstract away spacing logic for a wx.BoxSizer | ||
| """ | ||
| def __init__(self, parent, orientation=None, sizer=None): | ||
| """ Init. Pass in either orientation OR sizer. | ||
| @param parent - An instance of the parent wx window. EG wx.Dialog | ||
| @param orientation: the orientation to use when constructing the sizer, either wx.HORIZONTAL or wx.VERTICAL | ||
| @type itemType: wx.HORIZONTAL or wx.VERTICAL | ||
| @param sizer: the sizer to use rather than constructing one. | ||
| @type sizer: wx.BoxSizer | ||
| """ | ||
| """ Init. Pass in either orientation OR sizer. | ||
| @param parent - An instance of the parent wx window. EG wx.Dialog | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| @param orientation: the orientation to use when constructing the sizer, either wx.HORIZONTAL or wx.VERTICAL | ||
| @type itemType: wx.HORIZONTAL or wx.VERTICAL | ||
| @param sizer: the sizer to use rather than constructing one. | ||
| @type sizer: wx.BoxSizer | ||
| """ | ||
| object.__init__(self) | ||
| self._parent = parent | ||
| self.hasFirstItemBeenAdded = False | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -138,9 +138,7 @@ def makeSettings(self, settingsSizer): | |
| languageChoices = [x[1] for x in self.languageNames] | ||
| # Translators: The label for a setting in general settings to select NVDA's interface language (once selected, NVDA must be restarted; the option user default means the user's Windows language will be used). | ||
| languageLabelText = _("&Language (requires restart to fully take effect):") | ||
| # Translators: The list of languages for NVDA. | ||
| languageCtrlName = _("Language") | ||
| self.languageList=settingsSizerHelper.addLabeledControl(languageLabelText, wx.Choice, name=languageCtrlName, choices=languageChoices) | ||
| self.languageList=settingsSizerHelper.addLabeledControl(languageLabelText, wx.Choice, choices=languageChoices) | ||
| self.languageList.SetToolTip(wx.ToolTip("Choose the language NVDA's messages and user interface should be presented in.")) | ||
| try: | ||
| self.oldLanguage=config.conf["general"]["language"] | ||
|
|
@@ -170,10 +168,8 @@ def makeSettings(self, settingsSizer): | |
|
|
||
| # Translators: The label for a setting in general settings to select logging level of NVDA as it runs (available options and what they are logged are found under comments for the logging level messages themselves). | ||
| logLevelLabelText=_("L&ogging level:") | ||
| # Translators: A combo box to choose log level (possible options are info, debug warning, input/output and debug). | ||
| logLevelChoicesName=_("Log level") | ||
| logLevelChoices = [name for level, name in self.LOG_LEVELS] | ||
| self.logLevelList = settingsSizerHelper.addLabeledControl(logLevelLabelText, wx.Choice, name=logLevelChoicesName, choices=logLevelChoices) | ||
| self.logLevelList = settingsSizerHelper.addLabeledControl(logLevelLabelText, wx.Choice, choices=logLevelChoices) | ||
| curLevel = log.getEffectiveLevel() | ||
| for index, (level, name) in enumerate(self.LOG_LEVELS): | ||
| if level == curLevel: | ||
|
|
@@ -433,7 +429,7 @@ def makeSettingControl(self,setting): | |
| """ | ||
| sizer=wx.BoxSizer(wx.HORIZONTAL) | ||
| label=wx.StaticText(self,wx.ID_ANY,label="%s:"%setting.displayNameWithAccelerator) | ||
| slider=VoiceSettingsSlider(self,wx.ID_ANY,minValue=0,maxValue=100,name="%s:"%setting.i18nName) | ||
| slider=VoiceSettingsSlider(self,wx.ID_ANY,minValue=0,maxValue=100) | ||
| setattr(self,"%sSlider"%setting.name,slider) | ||
| slider.Bind(wx.EVT_SLIDER,SynthSettingChanger(setting)) | ||
| self._setSliderStepSizes(slider,setting) | ||
|
|
@@ -452,7 +448,7 @@ def makeStringSettingControl(self,setting): | |
| synth=getSynth() | ||
| setattr(self,"_%ss"%setting.name,getattr(synth,"available%ss"%setting.name.capitalize()).values()) | ||
| l=getattr(self,"_%ss"%setting.name)### | ||
| labeledControl=guiHelper.LabeledControlHelper(self, labelText, wx.Choice, name="%s:"%setting.i18nName, choices=[x.name for x in l]) | ||
| labeledControl=guiHelper.LabeledControlHelper(self, labelText, wx.Choice, choices=[x.name for x in l]) | ||
| lCombo = labeledControl.control | ||
| setattr(self,"%sList"%setting.name,lCombo) | ||
| try: | ||
|
|
@@ -622,12 +618,10 @@ def makeSettings(self, settingsSizer): | |
| # Translators: This is the label for a combobox in the | ||
| # keyboard settings dialog. | ||
| kbdLabelText = _("&Keyboard layout:") | ||
| # Translators: This is the name of a combobox in the keyboard settings dialog. | ||
| kbdChoicesName = _("Keyboard layout") | ||
| layouts=keyboardHandler.KeyboardInputGesture.LAYOUTS | ||
| self.kbdNames=sorted(layouts) | ||
| kbdChoices = [layouts[layout] for layout in self.kbdNames] | ||
| self.kbdList=sHelper.addLabeledControl(kbdLabelText, wx.Choice, name=kbdChoicesName, choices=kbdChoices) | ||
| self.kbdList=sHelper.addLabeledControl(kbdLabelText, wx.Choice, choices=kbdChoices) | ||
| try: | ||
| index=self.kbdNames.index(config.conf['keyboard']['keyboardLayout']) | ||
| self.kbdList.SetSelection(index) | ||
|
|
@@ -759,12 +753,10 @@ def makeSettings(self, settingsSizer): | |
| # Translators: This is the label for a combobox in the | ||
| # mouse settings dialog. | ||
| textUnitLabelText=_("Text &unit resolution:") | ||
| # Translators: This is the name of a combobox in the mouse settings dialog. | ||
| textUnitsName = _("text reporting unit") | ||
| import textInfos | ||
| self.textUnits=[textInfos.UNIT_CHARACTER,textInfos.UNIT_WORD,textInfos.UNIT_LINE,textInfos.UNIT_PARAGRAPH] | ||
| textUnitsChoices = [textInfos.unitLabels[x] for x in self.textUnits] | ||
| self.textUnitComboBox=sHelper.addLabeledControl(textUnitLabelText, wx.Choice, name=textUnitsName, choices=textUnitsChoices) | ||
| self.textUnitComboBox=sHelper.addLabeledControl(textUnitLabelText, wx.Choice, choices=textUnitsChoices) | ||
| try: | ||
| index=self.textUnits.index(config.conf["mouse"]["mouseTextUnit"]) | ||
| except: | ||
|
|
@@ -943,11 +935,8 @@ def makeSettings(self, settingsSizer): | |
| # Translators: This is the label for a combobox in the | ||
| # object presentation settings dialog. | ||
| progressLabelText = _("Progress &bar output:") | ||
| # Translators: This is the name of a combobox in the | ||
| # object presentation settings dialog. | ||
| progressName=_("Progress bar output") | ||
| progressChoices = [name for setting, name in self.progressLabels] | ||
| self.progressList=sHelper.addLabeledControl(progressLabelText, wx.Choice,name=progressName,choices=progressChoices) | ||
| self.progressList=sHelper.addLabeledControl(progressLabelText, wx.Choice,choices=progressChoices) | ||
| for index, (setting, name) in enumerate(self.progressLabels): | ||
| if setting == config.conf["presentation"]["progressBarUpdates"]["progressBarOutputMode"]: | ||
| self.progressList.SetSelection(index) | ||
|
|
@@ -1813,7 +1802,7 @@ def makeSettings(self, settingsSizer): | |
| filterLabel = wx.StaticText(self, label=pgettext("inputGestures", "&Filter by:")) | ||
| filter = wx.TextCtrl(self) | ||
| filterSizer.Add(filterLabel, flag=wx.ALIGN_CENTER_VERTICAL) | ||
| filterSizer.AddSpacer(guiHelper.SPACE_BETWEEN_LABEL_CONTROL_HORIZONTAL) | ||
| filterSizer.AddSpacer(guiHelper.SPACE_BETWEEN_ASSOCIATED_CONTROL_HORIZONTAL) | ||
| filterSizer.Add(filter, proportion=1) | ||
| settingsSizer.Add(filterSizer, flag=wx.EXPAND) | ||
| settingsSizer.AddSpacer(5) | ||
|
|
@@ -1828,22 +1817,23 @@ def makeSettings(self, settingsSizer): | |
| self.gestures = inputCore.manager.getAllGestureMappings(obj=gui.mainFrame.prevFocus, ancestors=gui.mainFrame.prevFocusAncestors) | ||
| self.populateTree() | ||
|
|
||
| settingsSizer.AddSpacer(guiHelper.SPACE_BETWEEN_ASSOCIATED_CONTROL_VERTICAL) | ||
|
|
||
| buttonSizer = wx.BoxSizer(wx.HORIZONTAL) | ||
| # Translators: The label of a button to add a gesture in the Input Gestures dialog. | ||
| item = self.addButton = wx.Button(self, label=_("&Add")) | ||
| item.Bind(wx.EVT_BUTTON, self.onAdd) | ||
| item.Disable() | ||
| buttonSizer.Add(item) | ||
| buttonSizer.AddSpacer(guiHelper.SPACE_BETWEEN_BUTTONS) | ||
| buttonSizer.AddSpacer(guiHelper.SPACE_BETWEEN_BUTTONS_HORIZONTAL) | ||
| # Translators: The label of a button to remove a gesture in the Input Gestures dialog. | ||
| item = self.removeButton = wx.Button(self, label=_("&Remove")) | ||
| item.Bind(wx.EVT_BUTTON, self.onRemove) | ||
| item.Disable() | ||
| self.pendingAdds = set() | ||
| self.pendingRemoves = set() | ||
| buttonSizer.Add(item) | ||
| buttonSizer.AddSpacer(guiHelper.SPACE_BETWEEN_BUTTONS) | ||
| settingsSizer.Add(buttonSizer, border=guiHelper.SPACE_BETWEEN_BUTTONS, flag=wx.ALL) | ||
| settingsSizer.Add(buttonSizer) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm almost certainly missing something, but... why not use a Buttonhelper here? |
||
|
|
||
| def postInit(self): | ||
| self.tree.SetFocus() | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to have
kwargshere? You could just pass theflagargument directly.