diff --git a/src/model/Serializable.py b/src/model/Serializable.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b65cd72a788100814f564bf06095cd114af15c --- /dev/null +++ b/src/model/Serializable.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- + +import pickle + +class Serializable(): + def __init__(self, filename): + self.filename = filename + + @classmethod + def open(cls, filename): + with open(filename, 'rb') as in_file: + me = pickle.load(in_file) + return me + + def save(self): + with open(self.filename, 'wb') as out_file: + pickle.dump(self, out_file) diff --git a/src/model/Study.py b/src/model/Study.py new file mode 100644 index 0000000000000000000000000000000000000000..5379ed9653aef8639040d70bb15ff79cd994112e --- /dev/null +++ b/src/model/Study.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +import os +from datetime import datetime +from model.Serializable import Serializable + +class Study(Serializable): + def __init__(self, name, filename, data): + # Serialization information + super(Study, self).__init__(filename) + self.filename = filename + + # Study general information + self.name = name + self.comment = "" + + self.creation_date = datetime.now() + self.last_modification_date = datetime.now() + self.last_save_date = datetime.now() + + # Study data + self.data = data + + @classmethod + def new(cls, name, filename): + return cls(name, filename, {}) diff --git a/src/pamhyr.py b/src/pamhyr.py index 206755c7c65da3f327a6ad894148490c62320abb..7c755d882b07caa5599a5ddd88a36961f39d687a 100755 --- a/src/pamhyr.py +++ b/src/pamhyr.py @@ -3,14 +3,18 @@ import sys -from PyQt5.QtWidgets import ( - QMainWindow, QApplication, -) +from PyQt5.QtWidgets import QApplication from view.MainWindow import ApplicationWindow +from model.Study import Study + +class Application(ApplicationWindow): + def __init__(self): + super(Application, self).__init__() + self.study = Study.new("dummy", "dummy.pkl") def main(): app = QApplication(sys.argv) - application = ApplicationWindow() + application = Application() application.show() sys.exit(app.exec_()) diff --git a/src/view/MainWindow.py b/src/view/MainWindow.py index 0466c4e5193f724c31368bf7e392d30d929f7114..399d4d5ea1fb259994c42c2e50ff2fd5a2a0313b 100644 --- a/src/view/MainWindow.py +++ b/src/view/MainWindow.py @@ -1,3 +1,7 @@ +# -*- coding: utf-8 -*- + +import os + from PyQt5 import QtGui from PyQt5.QtWidgets import ( QMainWindow, QApplication, @@ -7,5 +11,18 @@ from PyQt5.uic import loadUi class ApplicationWindow(QMainWindow): def __init__(self): super(ApplicationWindow, self).__init__() - self.ui = loadUi("view/ui/MainWindow.ui", self) + self.ui = loadUi( + os.path.join(os.path.dirname(__file__), "ui", "MainWindow.ui"), + self + ) + self.set_icon() self.showMaximized() + + def set_icon(self): + """ + Returns: Add icon to application window + """ + icon = QtGui.QIcon() + _path= os.path.join(os.path.dirname(__file__), "ui", "resources", "M_icon.png") + icon.addPixmap(QtGui.QPixmap(f"{_path}"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.setWindowIcon(icon) diff --git a/src/view/ui/resources/M_icon.png b/src/view/ui/resources/M_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..9927c06efd799b96507e826240a908242cdaf98b Binary files /dev/null and b/src/view/ui/resources/M_icon.png differ