PamHyr: Add model scheme and set application icon.

This commit is contained in:
Pierre-Antoine Rouby committed 2023-03-06 11:42:05 +01:00
1 parent 67913ab8e5
commit 0e8b8c5c7a
5 files changed
+69 -5

No files matched your search

+17
View File
@@ -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)
+26
View File
@@ -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, {})
+8 -4
View File
@@ -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_())
+18 -1
View File
@@ -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)
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB