def resize_plot_item_list(lst, size, item_type, parent):
 n = len(lst)
 if (n > size):
  for i in lst[size:]:
   i.setParentItem(None)
   if i.scene():
    i.scene().removeItem(i)
  del lst[size:]
 elif (n < size):
  lst.extend((item_type(parent) for i in range((size - n))))

def resize_plot_item_list ( lst , size , item_type , parent ) : n = len ( lst ) if ( n > size ) : for i in lst [ size : ] : i . setParentItem ( None ) if i . scene ( ) : i . scene ( ) . removeItem ( i ) del lst [ size : ] elif ( n < size ) : lst . extend ( ( item_type ( parent ) for i in range ( ( size - n ) ) ) )
efficiently resizes a list of qgraphicsitems .