-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.py
42 lines (34 loc) · 1012 Bytes
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""'
Description: Model portion of MVC design pattern
"""
__author__ = "John DeBoard"
__email__ = "[email protected]"
__date__ = "2023-10-18"
__modified__ = "2024-06-21"
__version__ = "1.0.0.0"
from PySide2.QtCore import Slot, Signal, QObject
import view
class Model(QObject):
"""
model class for MVC design pattern
model updates view
model is updated by controller
"""
data_sig = Signal(str)
def __init__(self, aview, parent=None):
"""constructor"""
super().__init__(parent)
self.incr: int
self.data: str
self.mview: view.View
self.mview = aview
self.incr = 0
self.data = "default"
self.data_sig.connect(self.mview.update_data)
@Slot(str)
def update_data(self, arg):
"""new data signal from controller"""
self.data = arg
self.incr = self.incr + 1
print("Model data set to: " + self.data)
self.data_sig.emit(str(self.incr) + ":" + self.data)