[res] use resources to create icons

This commit is contained in:
Jan Grewe 2021-09-02 16:03:49 +02:00
parent 661529efb2
commit 8ad1197d2c
2 changed files with 11 additions and 8 deletions

3
nixview/nixview.py Executable file → Normal file
View File

@ -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)

View File

@ -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"))