May-03-2021, 09:30 PM
I would swear that I tried this before and it threw up all over me. Now it works fine.
class BaseView(): """Abstract base class for views""" def __init__(self): self.update_list = UpdateList(1.0) def showEvent(self, event): """Start update loop when window is shown""" self.upload() self.update_list.start() event.accept() def closeEvent(self, event): """Stop update loop when window is closed""" self.update_list.stop() event.accept() def upload(self): """Forward update message to all ValueControl objects""" if self.isVisible(): for child in self.children(): if isinstance(child, ValueControl): child.update_value() class View(QtWidgets.QWidget, BaseView): """Add upload and update loop to QWidget""" def __init__(self, *args, **kwargs): BaseView.__init__(self) QtWidgets.QWidget.__init__(self, *args, **kwargs)