code: def clear(self):
          
          layout = self.layout()
          for index in reversed(range(layout.count())):
              item = layout.takeAt(index)
              try:
                  item.widget().deleteLater()
              except AttributeError:
                  item = None
docs: Removes all child widgets.