[about] add about dialog
This commit is contained in:
parent
0c6bb8b687
commit
93d552265f
57
nixview/ui/about.py
Normal file
57
nixview/ui/about.py
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
from PyQt5.QtGui import QPixmap
|
||||||
|
import nixview.constants as cnst
|
||||||
|
import nixview.info
|
||||||
|
|
||||||
|
from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QLabel, QPushButton, QTextEdit, QVBoxLayout, QWidget
|
||||||
|
from PyQt5.QtCore import Qt, pyqtSignal
|
||||||
|
|
||||||
|
class AboutDialog(QDialog):
|
||||||
|
|
||||||
|
def __init__(self, parent=None) -> None:
|
||||||
|
super().__init__(parent=parent)
|
||||||
|
self.setModal(True)
|
||||||
|
about = About(self)
|
||||||
|
self.setLayout(QVBoxLayout())
|
||||||
|
self.layout().addWidget(about)
|
||||||
|
bbox = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok)
|
||||||
|
bbox.accepted.connect(self.accept)
|
||||||
|
self.layout().addWidget(bbox)
|
||||||
|
|
||||||
|
class About(QWidget):
|
||||||
|
|
||||||
|
def __init__(self, parent=None) -> None:
|
||||||
|
super().__init__(parent=parent)
|
||||||
|
self.setLayout(QVBoxLayout())
|
||||||
|
|
||||||
|
heading = QLabel("NixView")
|
||||||
|
font = heading.font()
|
||||||
|
font.setPointSize(18)
|
||||||
|
font.setBold(True)
|
||||||
|
heading.setFont(font)
|
||||||
|
heading.setAlignment(Qt.AlignCenter)
|
||||||
|
subheading = QLabel("viewer for nix data files\nby Jan Grewe")
|
||||||
|
subheading.setAlignment(Qt.AlignCenter)
|
||||||
|
nix_link = QLabel("https://github.com/g-node/nix")
|
||||||
|
nix_link.setOpenExternalLinks(True)
|
||||||
|
nix_link.setAlignment(Qt.AlignCenter)
|
||||||
|
rtd_link = QLabel("https://nixio.readthedocs.io/en/master/")
|
||||||
|
rtd_link.setOpenExternalLinks(True)
|
||||||
|
rtd_link.setAlignment(Qt.AlignCenter)
|
||||||
|
|
||||||
|
iconlabel = QLabel()
|
||||||
|
pixmap = QPixmap(os.path.join(cnst.ICONS_FOLDER, "nix_logo.png"))
|
||||||
|
s = pixmap.size()
|
||||||
|
new_height = int(s.height() * 300/s.width())
|
||||||
|
pixmap = pixmap.scaled(300, new_height, Qt.KeepAspectRatio, Qt.FastTransformation)
|
||||||
|
iconlabel.setPixmap(pixmap)
|
||||||
|
iconlabel.setMaximumWidth(300)
|
||||||
|
iconlabel.setAlignment(Qt.AlignCenter)
|
||||||
|
iconlabel.setScaledContents(True)
|
||||||
|
|
||||||
|
self.layout().addWidget(heading)
|
||||||
|
self.layout().addWidget(subheading)
|
||||||
|
self.layout().addWidget(iconlabel)
|
||||||
|
self.layout().addWidget(nix_link)
|
||||||
|
self.layout().addWidget(rtd_link)
|
@ -8,6 +8,7 @@ from nixview.file_handler import FileHandler, NodeType
|
|||||||
import nixview.constants as cnst
|
import nixview.constants as cnst
|
||||||
import nixview.communicator as comm
|
import nixview.communicator as comm
|
||||||
from nixview.ui.central_widget import CentralWidget
|
from nixview.ui.central_widget import CentralWidget
|
||||||
|
from nixview.ui.about import AboutDialog
|
||||||
|
|
||||||
|
|
||||||
class NixView(QMainWindow):
|
class NixView(QMainWindow):
|
||||||
@ -68,6 +69,12 @@ class NixView(QMainWindow):
|
|||||||
self._table_action.setShortcut(QKeySequence("Ctrl+t"))
|
self._table_action.setShortcut(QKeySequence("Ctrl+t"))
|
||||||
self._table_action.setEnabled(False)
|
self._table_action.setEnabled(False)
|
||||||
# self._table_action.triggered.connect(self.on_file_close)
|
# self._table_action.triggered.connect(self.on_file_close)
|
||||||
|
|
||||||
|
self._about_action = QAction("about")
|
||||||
|
self._about_action.setStatusTip("Show about dialog")
|
||||||
|
self._about_action.setEnabled(True)
|
||||||
|
self._about_action.triggered.connect(self.on_about)
|
||||||
|
|
||||||
self.create_toolbar()
|
self.create_toolbar()
|
||||||
self.create_menu()
|
self.create_menu()
|
||||||
|
|
||||||
@ -103,6 +110,8 @@ class NixView(QMainWindow):
|
|||||||
plot_menu.addAction(self._plot_action)
|
plot_menu.addAction(self._plot_action)
|
||||||
plot_menu.addAction(self._table_action)
|
plot_menu.addAction(self._table_action)
|
||||||
|
|
||||||
|
help_menu = menu.addMenu("&Help")
|
||||||
|
help_menu.addAction(self._about_action)
|
||||||
self.setMenuBar(menu)
|
self.setMenuBar(menu)
|
||||||
|
|
||||||
def _update_recent_files(self, filename):
|
def _update_recent_files(self, filename):
|
||||||
@ -147,3 +156,7 @@ class NixView(QMainWindow):
|
|||||||
def on_item_plot(self, s):
|
def on_item_plot(self, s):
|
||||||
if self._current_item is not None:
|
if self._current_item is not None:
|
||||||
self._cw.plot_item(self._current_item)
|
self._cw.plot_item(self._current_item)
|
||||||
|
|
||||||
|
def on_about(self, e):
|
||||||
|
about = AboutDialog(self)
|
||||||
|
about.show()
|
7
setup.py
7
setup.py
@ -25,6 +25,8 @@ with open(README) as f:
|
|||||||
|
|
||||||
packages = [
|
packages = [
|
||||||
"nixview",
|
"nixview",
|
||||||
|
"nixview.ui",
|
||||||
|
"nixview.data_models"
|
||||||
]
|
]
|
||||||
|
|
||||||
install_req = ["nixio>=1.4.0", "PyQt5"]
|
install_req = ["nixio>=1.4.0", "PyQt5"]
|
||||||
@ -48,5 +50,8 @@ setup(
|
|||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
classifiers=CLASSIFIERS,
|
classifiers=CLASSIFIERS,
|
||||||
license="BSD",
|
license="BSD",
|
||||||
entry_points={"gui_scripts": ["nixview = nixview:main []"]}
|
entry_points={
|
||||||
|
"gui_scripts": ["nixview = nixview:main []"],
|
||||||
|
"console_scripts": ["nixview = nixview:main []"]
|
||||||
|
}
|
||||||
)
|
)
|
Loading…
Reference in New Issue
Block a user