@@ -209,11 +209,30 @@ def is_edit_valid(edit):
209
209
class FormWidget (QtWidgets .QWidget ):
210
210
update_buttons = QtCore .Signal ()
211
211
212
- def __init__ (self , data , comment = "" , parent = None ):
212
+ def __init__ (self , data , comment = "" , with_margin = False , parent = None ):
213
+ """
214
+
215
+ Parameters
216
+ ----------
217
+ data : list of (label, value) pairs
218
+ The data to be edited in the form.
219
+ comment : str
220
+
221
+ no_margin : bool, optional, default: False
222
+ By default, the FormWidget has a margin around the form elements.
223
+ This correct if the widget is a single element within another
224
+ widget, e.g. a tab. However, if the FormWidget is part of a layout
225
+ with
226
+ is correct if the F
227
+ parent : QWidget or None
228
+ The parent widget.
229
+ """
213
230
QtWidgets .QWidget .__init__ (self , parent )
214
231
self .data = copy .deepcopy (data )
215
232
self .widgets = []
216
233
self .formlayout = QtWidgets .QFormLayout (self )
234
+ if not with_margin :
235
+ self .formlayout .setContentsMargins (0 , 0 , 0 , 0 )
217
236
if comment :
218
237
self .formlayout .addRow (QtWidgets .QLabel (comment ))
219
238
self .formlayout .addRow (QtWidgets .QLabel (" " ))
@@ -370,13 +389,14 @@ def __init__(self, datalist, comment="", parent=None):
370
389
layout = QtWidgets .QVBoxLayout ()
371
390
self .tabwidget = QtWidgets .QTabWidget ()
372
391
layout .addWidget (self .tabwidget )
392
+ layout .setContentsMargins (0 , 0 , 0 , 0 )
373
393
self .setLayout (layout )
374
394
self .widgetlist = []
375
395
for data , title , comment in datalist :
376
396
if len (data [0 ]) == 3 :
377
397
widget = FormComboWidget (data , comment = comment , parent = self )
378
398
else :
379
- widget = FormWidget (data , comment = comment , parent = self )
399
+ widget = FormWidget (data , with_margin = True , comment = comment )
380
400
index = self .tabwidget .addTab (widget , title )
381
401
self .tabwidget .setTabToolTip (index , comment )
382
402
self .widgetlist .append (widget )
@@ -405,8 +425,7 @@ def __init__(self, data, title="", comment="",
405
425
self .formwidget = FormComboWidget (data , comment = comment ,
406
426
parent = self )
407
427
else :
408
- self .formwidget = FormWidget (data , comment = comment ,
409
- parent = self )
428
+ self .formwidget = FormWidget (data , comment = comment , parent = self )
410
429
layout = QtWidgets .QVBoxLayout ()
411
430
layout .addWidget (self .formwidget )
412
431
0 commit comments