@@ -247,23 +247,23 @@ def addItem(self, item, **keywordArgs):
247247
248248 if isinstance (item , ButtonHelper ):
249249 toAdd = item .sizer
250- buttonBorderAmount = 5
251- keywordArgs . update ({ 'border' : buttonBorderAmount , 'flag' : wx .ALL })
250+ keywordArgs [ "border" ] = 5
251+ keywordArgs [ "flag" ] = keywordArgs . get ( "flag" , 0 ) | wx .ALL
252252 shouldAddSpacer = False # no need to add a spacer, since the button border has been added.
253253 elif isinstance (item , BoxSizerHelper ):
254254 toAdd = item .sizer
255255 elif isinstance (item , PathSelectionHelper ):
256256 toAdd = item .sizer
257257 if self .sizer .GetOrientation () == wx .VERTICAL :
258- keywordArgs ['flag' ] = wx .EXPAND
258+ keywordArgs ['flag' ] = keywordArgs . get ( "flag" , 0 ) | wx .EXPAND
259259 else :
260260 raise NotImplementedError ("Adding PathSelectionHelper to a horizontal BoxSizerHelper is not implemented" )
261261 elif isinstance (item , LabeledControlHelper ):
262262 raise NotImplementedError ("Use addLabeledControl instead" )
263263
264264 # a boxSizerHelper could contain a wx.StaticBoxSizer
265265 if isinstance (toAdd , (wx .StaticBoxSizer , scrolledpanel .ScrolledPanel )):
266- keywordArgs ['flag' ] = wx .EXPAND
266+ keywordArgs ['flag' ] = keywordArgs . get ( "flag" , 0 ) | wx .EXPAND
267267
268268 if shouldAddSpacer :
269269 self .sizer .AddSpacer (SPACE_BETWEEN_VERTICAL_DIALOG_ITEMS )
@@ -289,19 +289,34 @@ def addLabeledControl(self, labelText, wxCtrlClass, **kwargs):
289289 self .addItem (labeledControl .sizer )
290290 return labeledControl .control
291291
292- def addDialogDismissButtons (self , buttons ):
292+ def addDialogDismissButtons (self , buttons , separated = False ):
293293 """ Adds and aligns the buttons for dismissing the dialog; e.g. "ok | cancel". These buttons are expected
294294 to be the last items added to the dialog. Buttons that launch an action, do not dismiss the dialog, or are not
295295 the last item should be added via L{addItem}
296- @param buttons: the buttons to add
297- @type buttons: wx.Sizer or guiHelper.ButtonHelper or single wx.Button
296+ @param buttons: The buttons to add
297+ @type buttons:
298+ wx.Sizer or guiHelper.ButtonHelper or single wx.Button
299+ or a bit list of the following flags: wx.OK, wx.CANCEL, wx.YES, wx.NO, wx.APPLY, wx.CLOSE,
300+ wx.HELP, wx.NO_DEFAULT
301+ @param separated:
302+ Whether a separator should be added between the dialog content and its footer.
303+ Should be set to L{False} for message or single input dialogs, L{True} otherwise.
304+ @type separated: L{bool}
298305 """
306+ if self .sizer .GetOrientation () != wx .VERTICAL :
307+ raise NotImplementedError (
308+ "Adding dialog dismiss buttons to a horizontal BoxSizerHelper is not implemented."
309+ )
299310 if isinstance (buttons , ButtonHelper ):
300311 toAdd = buttons .sizer
301312 elif isinstance (buttons , (wx .Sizer , wx .Button )):
302313 toAdd = buttons
314+ elif isinstance (buttons , int ):
315+ toAdd = self ._parent .CreateButtonSizer (buttons )
303316 else :
304317 raise NotImplementedError ("Unknown type: {}" .format (buttons ))
318+ if separated :
319+ self .addItem (wx .StaticLine (self ._parent ), flag = wx .EXPAND )
305320 self .addItem (toAdd , flag = wx .ALIGN_RIGHT )
306321 self .dialogDismissButtonsAdded = True
307322 return buttons
0 commit comments