Skip to content
Closed
Show file tree
Hide file tree
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 Aug 19, 2016
825864f
fix general settings alignments
feerrenrut Aug 19, 2016
e13351d
fixed alignment in the synthesizer dialog
feerrenrut Aug 19, 2016
81cd171
fix alignment on voice settings dialog
feerrenrut Aug 19, 2016
c3f2a35
fix alignment on keyboard and mouse settings dialogs
feerrenrut Aug 19, 2016
fa3384c
fix alignment on braille settings dialogs
feerrenrut Aug 19, 2016
82b7dbf
fix alignment on the object presentation settings dialogs
feerrenrut Aug 19, 2016
1ba26ac
fix alignment on the dictionary dialog
feerrenrut Aug 19, 2016
dfacc70
fix alignment on the input gestures dialog
feerrenrut Aug 19, 2016
e710892
fix alignment on the configuration profiles dialog
feerrenrut Aug 22, 2016
c64f213
fix alignment on the new config profile dialog
feerrenrut Aug 22, 2016
173879f
fix alignment on the profile triggers dialog
feerrenrut Aug 22, 2016
531aaa9
Pull out common gui patterns into a helper module.
feerrenrut Aug 30, 2016
0cb617b
Show symbols on tree view
feerrenrut Aug 31, 2016
b3a05c4
fixed up alignment and spacing on the elements list dialog
feerrenrut Aug 31, 2016
4b8ab58
WIP
feerrenrut Sep 8, 2016
17e2c3a
Gui helper is now class based
feerrenrut Sep 12, 2016
899358e
Moved more of the code over to the class based approach
feerrenrut Sep 14, 2016
20c88e0
Updated comments for the guiHelper
feerrenrut Sep 15, 2016
108ee95
Fix some errors and remove 'name' parameter
feerrenrut Sep 16, 2016
8e93c71
Fixed up missed part of gui
feerrenrut Sep 17, 2016
a8ca09b
fix alignment on several dialogs
feerrenrut Sep 17, 2016
4b52d5d
Update some remainig dialogs
feerrenrut Sep 18, 2016
86548ae
minor fixes
feerrenrut Sep 19, 2016
ac401a8
Review actions for #6287
feerrenrut Sep 27, 2016
a262092
Fixed up an out of order comment for #6287
feerrenrut Sep 27, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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
feerrenrut committed Sep 19, 2016
commit 108ee95351009c5013fd4368e8f2b4e8b62a5b33
73 changes: 36 additions & 37 deletions source/gui/guiHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to have kwargs here? You could just pass the flag argument directly.

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
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

: instead of -

@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
Expand Down
34 changes: 12 additions & 22 deletions source/gui/settingsDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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()
Expand Down