def uniform_layout_helper(items, contents_rect, expanding, spacing):
 if (len(items) == 0):
  return
 spacing_space = ((len(items) - 1) * spacing)
 if (expanding == Qt.Horizontal):
  space = (contents_rect.width() - spacing_space)
  setter = (lambda w, s: w.setFixedWidth(max(s, 0)))
 else:
  space = (contents_rect.height() - spacing_space)
  setter = (lambda w, s: w.setFixedHeight(max(s, 0)))
 base_size = (space / len(items))
 remainder = (space % len(items))
 for (i, item) in enumerate(items):
  item_size = (base_size + (1 if (i < remainder) else 0))
  setter(item, item_size)

def uniform_layout_helper ( items , contents_rect , expanding , spacing ) : if ( len ( items ) == 0 ) : return spacing_space = ( ( len ( items ) - 1 ) * spacing ) if ( expanding == Qt . Horizontal ) : space = ( contents_rect . width ( ) - spacing_space ) setter = ( lambda w , s : w . setFixedWidth ( max ( s , 0 ) ) ) else : space = ( contents_rect . height ( ) - spacing_space ) setter = ( lambda w , s : w . setFixedHeight ( max ( s , 0 ) ) ) base_size = ( space / len ( items ) ) remainder = ( space % len ( items ) ) for ( i , item ) in enumerate ( items ) : item_size = ( base_size + ( 1 if ( i < remainder ) else 0 ) ) setter ( item , item_size )
set fixed sizes on items so they can be laid out in contents_rect and fill the whole space .