def clear_layout(layout: QLayout) -> None:
    """Clear the layout off all its components"""
    if layout is not None:
        while layout.count():
            item = layout.takeAt(0)
            widget = item.widget()
            if widget is not None:
                widget.deleteLater()
            else:
                clear_layout(item.layout())
def clear_layout ( layout : QLayout ) -> None : if layout is not None : while layout . count ( ) : item = layout . takeAt ( 0 ) widget = item . widget ( ) if widget is not None : widget . deleteLater ( ) else : clear_layout ( item . layout ( ) )
Clear the layout off all its components