Skip to content

Commit

Permalink
try parent instead of sibling method
Browse files Browse the repository at this point in the history
  • Loading branch information
seanbudd committed Mar 16, 2021
1 parent 45514f2 commit e17de62
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 67 deletions.
3 changes: 1 addition & 2 deletions source/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,6 @@ def __init__(self, parent):
super(WelcomeDialog, self).__init__(parent, wx.ID_ANY, _("Welcome to NVDA"))

mainSizer=wx.BoxSizer(wx.VERTICAL)
mainSizerHelper = guiHelper.BoxSizerHelper(self, sizer=mainSizer)
# Translators: The header for the Welcome dialog when user starts NVDA for the first time. This is in larger,
# bold lettering
welcomeTextHeader = wx.StaticText(self, label=_("Welcome to NVDA!"))
Expand Down Expand Up @@ -808,7 +807,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 = guiHelper.LTRStaticBoxSizer(wx.VERTICAL, self, label=groupLabel)
sHelper.addItem(sizer.GetStaticBox())
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)
Expand Down
12 changes: 9 additions & 3 deletions source/gui/guiHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.sizer.GetStaticBox(), 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:
Expand All @@ -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."
Expand All @@ -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.sizer.GetStaticBox().CreateButtonSizer(buttons)
toAdd = parent.CreateButtonSizer(buttons)
else:
raise NotImplementedError("Unknown type: {}".format(buttons))
if separated:
self.addItem(wx.StaticLine(self.sizer.GetStaticBox()), flag=wx.EXPAND)
self.addItem(wx.StaticLine(parent), flag=wx.EXPAND)
self.addItem(toAdd, flag=wx.ALIGN_RIGHT)
self.dialogDismissButtonsAdded = True
return buttons
Expand Down
Loading

0 comments on commit e17de62

Please sign in to comment.