mirror of https://gitlab.com/pamhyr/pamhyr2
PamHyr: Add model scheme and set application icon.
parent
67913ab8e5
commit
0e8b8c5c7a
|
|
@ -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)
|
||||||
|
|
@ -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, {})
|
||||||
|
|
@ -3,14 +3,18 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import QApplication
|
||||||
QMainWindow, QApplication,
|
|
||||||
)
|
|
||||||
from view.MainWindow import ApplicationWindow
|
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():
|
def main():
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
application = ApplicationWindow()
|
application = Application()
|
||||||
application.show()
|
application.show()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
from PyQt5 import QtGui
|
from PyQt5 import QtGui
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QMainWindow, QApplication,
|
QMainWindow, QApplication,
|
||||||
|
|
@ -7,5 +11,18 @@ from PyQt5.uic import loadUi
|
||||||
class ApplicationWindow(QMainWindow):
|
class ApplicationWindow(QMainWindow):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(ApplicationWindow, self).__init__()
|
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()
|
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 |
Loading…
Reference in New Issue