def grid(margin, spacing, *widgets):
 layout = QtWidgets.QGridLayout()
 layout.setSpacing(spacing)
 set_margin(layout, margin)
 for row in widgets:
  item = row[0]
  if isinstance(item, QtWidgets.QWidget):
   layout.addWidget(*row)
  elif isinstance(item, QtWidgets.QLayoutItem):
   layout.addItem(*row)
 return layout

def grid ( margin , spacing , * widgets ) : layout = QtWidgets . QGridLayout ( ) layout . setSpacing ( spacing ) set_margin ( layout , margin ) for row in widgets : item = row [ 0 ] if isinstance ( item , QtWidgets . QWidget ) : layout . addWidget ( * row ) elif isinstance ( item , QtWidgets . QLayoutItem ) : layout . addItem ( * row ) return layout
create a qgridlayout with the specified sizes and items .