From 8ad1197d2ce56743b6faf57540d5ee4d854ac6dc Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Thu, 2 Sep 2021 16:03:49 +0200 Subject: [PATCH] [res] use resources to create icons --- nixview/nixview.py | 3 +++ nixview/ui/mainwindow.py | 16 ++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) mode change 100755 => 100644 nixview/nixview.py diff --git a/nixview/nixview.py b/nixview/nixview.py old mode 100755 new mode 100644 index c7e86ce..b21ed34 --- a/nixview/nixview.py +++ b/nixview/nixview.py @@ -1,6 +1,7 @@ #!/usr/bin/python3 import sys from PyQt5.QtWidgets import QApplication +from PyQt5.QtGui import QIcon from nixview.ui.mainwindow import NixView import argparse @@ -10,6 +11,8 @@ def main(): parser.add_argument("file", nargs="?", default="", type=str, help="The nix file that should be opened.") args = parser.parse_args() app = QApplication(sys.argv) + if platform.system() == 'Linux': + app.setWindowIcon(QIcon(":/icons/app_icon_png")) window = NixView() window.setMinimumWidth(800) window.setMinimumHeight(600) diff --git a/nixview/ui/mainwindow.py b/nixview/ui/mainwindow.py index 4857cfd..efe3e27 100644 --- a/nixview/ui/mainwindow.py +++ b/nixview/ui/mainwindow.py @@ -1,6 +1,6 @@ import sys from PyQt5.QtWidgets import QWidget, QFileDialog, QMainWindow, QMenuBar, QToolBar, QAction, QStatusBar, QSizePolicy -from PyQt5.QtGui import QKeySequence +from PyQt5.QtGui import QKeySequence, QIcon from PyQt5.QtCore import QSize, QSettings, Qt from nixview.util.file_handler import FileHandler, NodeType @@ -17,7 +17,7 @@ class NixView(QMainWindow): super(NixView, self).__init__(*args, **kwargs) self._current_item = None self.setWindowTitle("NixView") - self.setWindowIcon(cnst.get_icon('nixview')) + #self.setWindowIcon(cnst.get_icon('nixview')) self._file_handler = FileHandler() self.setStatusBar(QStatusBar(self)) @@ -50,29 +50,29 @@ class NixView(QMainWindow): self._table_action.setEnabled(enable) def create_actions(self): - self._file_open_action = QAction(cnst.get_icon("nixview_open"), "Open", self) + self._file_open_action = QAction(QIcon(":/icons/file_open"), "Open", self) self._file_open_action.setStatusTip("Open nix file") self._file_open_action.setShortcut(QKeySequence("Ctrl+o")) self._file_open_action.triggered.connect(self.on_file_open) - self._file_close_action = QAction(cnst.get_icon("nixview_close"), "Close", self) + self._file_close_action = QAction(QIcon(":/icons/file_close"), "Close", self) self._file_close_action.setStatusTip("Close current nix file") self._file_close_action.setShortcut(QKeySequence("Ctrl+w")) self._file_close_action.setEnabled(False) self._file_close_action.triggered.connect(self.on_file_close) - self._quit_action = QAction(cnst.get_icon("nixview_quit"), "Quit", self) + self._quit_action = QAction(QIcon(":/icons/app_quit"), "Quit", self) self._quit_action.setStatusTip("Close current file and quit") self._quit_action.setShortcut(QKeySequence("Ctrl+q")) self._quit_action.triggered.connect(self.on_quit) - self._plot_action = QAction(cnst.get_icon("nix_data_array"), "Plot", self) + self._plot_action = QAction(QIcon(":/icons/show_plot"), "Plot", self) self._plot_action.setStatusTip("Plot currently selected entity") self._plot_action.setShortcut(QKeySequence("Ctrl+p")) self._plot_action.setEnabled(False) self._plot_action.triggered.connect(self.on_item_plot) - self._table_action = QAction(cnst.get_icon("nix_data_frame"), "Show table", self) + self._table_action = QAction(QIcon(":/icons/show_table"), "Show table", self) self._table_action.setStatusTip("Show data as table") self._table_action.setShortcut(QKeySequence("Ctrl+t")) self._table_action.setEnabled(False) @@ -83,7 +83,7 @@ class NixView(QMainWindow): self._about_action.setEnabled(True) self._about_action.triggered.connect(self.on_about) - self._help_action = QAction(cnst.get_icon("nixview_help"), "help") + self._help_action = QAction(QIcon(":/icons/show_help"), "help") self._help_action.setStatusTip("Show help dialog") self._table_action.setShortcut(QKeySequence("F1"))