@@ -324,7 +324,10 @@ def addLabeledControl(self, labelText, wxCtrlClass, **kwargs):
324324 Relies on guiHelper.LabeledControlHelper and thus guiHelper.associateElements, and therefore inherits any
325325 limitations from there.
326326 """
327- labeledControl = LabeledControlHelper (self .sizer .GetStaticBox (), labelText , wxCtrlClass , ** kwargs )
327+ parent = self ._parent
328+ if isinstance (self .sizer , wx .StaticBoxSizer ):
329+ parent = self .sizer .GetStaticBox ()
330+ labeledControl = LabeledControlHelper (parent , labelText , wxCtrlClass , ** kwargs )
328331 if (isinstance (labeledControl .control , (wx .ListCtrl ,wx .ListBox ,wx .TreeCtrl ))):
329332 self .addItem (labeledControl .sizer , flag = wx .EXPAND , proportion = 1 )
330333 else :
@@ -345,6 +348,9 @@ def addDialogDismissButtons(self, buttons, separated=False):
345348 Should be set to L{False} for message or single input dialogs, L{True} otherwise.
346349 @type separated: L{bool}
347350 """
351+ parent = self ._parent
352+ if isinstance (self .sizer , wx .StaticBoxSizer ):
353+ parent = self .sizer .GetStaticBox ()
348354 if self .sizer .GetOrientation () != wx .VERTICAL :
349355 raise NotImplementedError (
350356 "Adding dialog dismiss buttons to a horizontal BoxSizerHelper is not implemented."
@@ -354,11 +360,11 @@ def addDialogDismissButtons(self, buttons, separated=False):
354360 elif isinstance (buttons , (wx .Sizer , wx .Button )):
355361 toAdd = buttons
356362 elif isinstance (buttons , int ):
357- toAdd = self . sizer . GetStaticBox () .CreateButtonSizer (buttons )
363+ toAdd = parent .CreateButtonSizer (buttons )
358364 else :
359365 raise NotImplementedError ("Unknown type: {}" .format (buttons ))
360366 if separated :
361- self .addItem (wx .StaticLine (self . sizer . GetStaticBox () ), flag = wx .EXPAND )
367+ self .addItem (wx .StaticLine (parent ), flag = wx .EXPAND )
362368 self .addItem (toAdd , flag = wx .ALIGN_RIGHT )
363369 self .dialogDismissButtonsAdded = True
364370 return buttons
0 commit comments