|
- 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)
复制代码
本帖寻求最佳方案
回复被采纳后将获得奖励 C币 5
,目前已有 1 个回复
我要奖励
|
|