moved asset loading into seperate file
This commit is contained in:
12
assets.py
Normal file
12
assets.py
Normal file
@ -0,0 +1,12 @@
|
||||
from PyQt5.QtGui import QIcon, QPixmap
|
||||
|
||||
|
||||
# These are function in order not to trigger:
|
||||
# Must construct a QGuiApplication before a QPixmap
|
||||
|
||||
logo = lambda: QPixmap("assets/logo.png")
|
||||
icon = lambda: QIcon("assets/icon.png")
|
||||
char = lambda: QIcon("assets/char.png")
|
||||
|
||||
|
||||
|
@ -4,6 +4,7 @@ from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QMainWindow, QSplitter
|
||||
from PyQt5.QtGui import QIcon
|
||||
|
||||
import assets
|
||||
from dictlist import DictList
|
||||
from mdi import MDIArea, MDISubPlot
|
||||
|
||||
@ -17,7 +18,7 @@ class MainWindow(QMainWindow):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.setWindowTitle(title)
|
||||
|
||||
self.setWindowIcon(QIcon("assets/icon.png"))
|
||||
self.setWindowIcon(assets.icon())
|
||||
|
||||
data = {
|
||||
"sine": [X, np.sin(X)],
|
||||
|
6
mdi.py
6
mdi.py
@ -2,6 +2,8 @@ from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QMdiArea, QMdiSubWindow, QAction
|
||||
from PyQt5.QtGui import QIcon, QPixmap, QPainter, QColor
|
||||
from pyqtgraph import PlotWidget
|
||||
|
||||
import assets
|
||||
from theme import MDI_BKG
|
||||
|
||||
|
||||
@ -16,7 +18,7 @@ class MDIArea(QMdiArea):
|
||||
menu.addAction("Close All")
|
||||
menu.triggered[QAction].connect(self.on_menu_select)
|
||||
|
||||
self.logo = QPixmap("assets/logo.png")
|
||||
self.logo = assets.logo()
|
||||
|
||||
|
||||
def on_menu_select(self, p):
|
||||
@ -60,7 +62,7 @@ class MDISubPlot(QMdiSubWindow):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.setWindowTitle(title)
|
||||
|
||||
self.setWindowIcon(QIcon("assets/char.png"))
|
||||
self.setWindowIcon(assets.char())
|
||||
|
||||
# without this, the SubWindow is not removed from the subWindowList
|
||||
self.setAttribute(Qt.WA_DeleteOnClose)
|
||||
|
Reference in New Issue
Block a user