[icons] revert back to the qt resource system for icons

This commit is contained in:
Jan Grewe 2024-09-30 10:03:29 +02:00
parent 09dd7f3d51
commit b0897bf52d
3 changed files with 6 additions and 9 deletions

View File

@ -8,7 +8,7 @@ from .ui.mainwindow import PyRelacs
from .util.logging import config_logging from .util.logging import config_logging
log = config_logging() log = config_logging()
from . import resources from . import resources # best created with pyside6-rcc resources.qrc -o resources.py (rcc produces an error...)
def main(): def main():
app = QApplication(sys.argv) app = QApplication(sys.argv)

View File

@ -1,5 +1,3 @@
import pathlib
from PyQt6.QtGui import QPixmap from PyQt6.QtGui import QPixmap
from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QLabel, QVBoxLayout, QWidget from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QLabel, QVBoxLayout, QWidget
from PyQt6.QtCore import Qt from PyQt6.QtCore import Qt
@ -40,8 +38,7 @@ class About(QWidget):
rtd_link.setAlignment(Qt.AlignmentFlag.AlignCenter) rtd_link.setAlignment(Qt.AlignmentFlag.AlignCenter)
iconlabel = QLabel() iconlabel = QLabel()
_root = pathlib.Path(__file__).parent.parent pixmap = QPixmap(":/icons/relacstuxheader.png")
pixmap = QPixmap(str(pathlib.Path.joinpath(_root, "icons/relacstuxheader.png")))
s = pixmap.size() s = pixmap.size()
new_height = int(s.height() * 300/s.width()) new_height = int(s.height() * 300/s.width())
pixmap = pixmap.scaled(300, new_height, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.FastTransformation) pixmap = pixmap.scaled(300, new_height, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.FastTransformation)

View File

@ -68,7 +68,7 @@ class PyRelacs(QMainWindow):
) )
def create_actions(self): def create_actions(self):
self._rlx_exitaction = QAction(QIcon(str(path.joinpath(_root, "icons/exit.png"))), "Exit", self) self._rlx_exitaction = QAction(QIcon(":/icons/exit.png"), "Exit", self)
self._rlx_exitaction.setStatusTip("Close relacs") self._rlx_exitaction.setStatusTip("Close relacs")
self._rlx_exitaction.setShortcut(QKeySequence("Alt+q")) self._rlx_exitaction.setShortcut(QKeySequence("Alt+q"))
self._rlx_exitaction.triggered.connect(self.on_exit) self._rlx_exitaction.triggered.connect(self.on_exit)
@ -78,17 +78,17 @@ class PyRelacs(QMainWindow):
self._rlx_aboutaction.setEnabled(True) self._rlx_aboutaction.setEnabled(True)
self._rlx_aboutaction.triggered.connect(self.on_about) self._rlx_aboutaction.triggered.connect(self.on_about)
self._daq_connectaction = QAction(QIcon(str(path.joinpath(_root, "icons/connect.png"))), "Connect DAQ", self) self._daq_connectaction = QAction(QIcon(":icons/connect.png"), "Connect DAQ", self)
self._daq_connectaction.setStatusTip("Connect to daq device") self._daq_connectaction.setStatusTip("Connect to daq device")
# self._daq_connectaction.setShortcut(QKeySequence("Alt+d")) # self._daq_connectaction.setShortcut(QKeySequence("Alt+d"))
self._daq_connectaction.triggered.connect(self.connect_dac) self._daq_connectaction.triggered.connect(self.connect_dac)
self._daq_disconnectaction = QAction(QIcon(str(path.joinpath(_root, "icons/disconnect.png"))), "Disconnect DAQ", self) self._daq_disconnectaction = QAction(QIcon(":/icons/disconnect.png"), "Disconnect DAQ", self)
self._daq_disconnectaction.setStatusTip("Disconnect the DAQ device") self._daq_disconnectaction.setStatusTip("Disconnect the DAQ device")
# self._daq_connectaction.setShortcut(QKeySequence("Alt+d")) # self._daq_connectaction.setShortcut(QKeySequence("Alt+d"))
self._daq_disconnectaction.triggered.connect(self.disconnect_dac) self._daq_disconnectaction.triggered.connect(self.disconnect_dac)
self._daq_calibaction = QAction(QIcon(str(path.joinpath(_root, "icons/calibration.png"))), "Plot calibration", self) self._daq_calibaction = QAction(QIcon(":/icons/calibration.png"), "Plot calibration", self)
self._daq_calibaction.setStatusTip("Calibrate the attenuator device") self._daq_calibaction.setStatusTip("Calibrate the attenuator device")
# self._daq_calibaction.setShortcut(QKeySequence("Alt+d")) # self._daq_calibaction.setShortcut(QKeySequence("Alt+d"))
self._daq_calibaction.triggered.connect(self.plot_calibration) self._daq_calibaction.triggered.connect(self.plot_calibration)