forked from awendt/pyrelacs
[about] add about dialog window
This commit is contained in:
parent
fe6e438189
commit
58decf0283
BIN
pyrelacs/icons/relacstuxheader.png
Normal file
BIN
pyrelacs/icons/relacstuxheader.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 255 KiB |
58
pyrelacs/ui/about.py
Normal file
58
pyrelacs/ui/about.py
Normal file
@ -0,0 +1,58 @@
|
||||
import os
|
||||
import pathlib
|
||||
|
||||
from PyQt6.QtGui import QPixmap
|
||||
from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QLabel, QVBoxLayout, QWidget
|
||||
from PyQt6.QtCore import Qt
|
||||
|
||||
|
||||
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("pyRelacs")
|
||||
font = heading.font()
|
||||
font.setPointSize(18)
|
||||
font.setBold(True)
|
||||
heading.setFont(font)
|
||||
heading.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
subheading = QLabel("relacsed electrophysiological recordings")
|
||||
subheading.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
nix_link = QLabel("https://github.com/bendalab")
|
||||
nix_link.setOpenExternalLinks(True)
|
||||
nix_link.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
rtd_link = QLabel("https://nixio.readthedocs.io/en/master/")
|
||||
rtd_link.setOpenExternalLinks(True)
|
||||
rtd_link.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
iconlabel = QLabel()
|
||||
_root = pathlib.Path(__file__).parent.parent
|
||||
pixmap = QPixmap(str(pathlib.Path.joinpath(_root, "icons/relacstuxheader.png")))
|
||||
s = pixmap.size()
|
||||
new_height = int(s.height() * 300/s.width())
|
||||
pixmap = pixmap.scaled(300, new_height, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.FastTransformation)
|
||||
iconlabel.setPixmap(pixmap)
|
||||
iconlabel.setMaximumWidth(300)
|
||||
iconlabel.setAlignment(Qt.AlignmentFlag.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)
|
@ -11,18 +11,20 @@ from PyQt6.QtWidgets import (
|
||||
QStatusBar
|
||||
)
|
||||
import uldaq
|
||||
import pathlib
|
||||
import numpy as np
|
||||
import nixio as nix
|
||||
import pyqtgraph as pg
|
||||
|
||||
from pathlib import Path as path
|
||||
from importlib.resources import files as rsrc_files
|
||||
from scipy.signal import welch, find_peaks
|
||||
|
||||
from pyrelacs.worker import Worker
|
||||
from ..worker import Worker
|
||||
from ..repros.repros import Repro
|
||||
from ..util.logging import config_logging
|
||||
from .about import AboutDialog
|
||||
log = config_logging()
|
||||
_root = path(__file__).parent.parent
|
||||
|
||||
from IPython import embed
|
||||
|
||||
@ -61,32 +63,33 @@ class PyRelacs(QMainWindow):
|
||||
widget.setLayout(layout)
|
||||
self.setCentralWidget(widget)
|
||||
|
||||
filename = pathlib.Path.joinpath(pathlib.Path.cwd(), "data.nix")
|
||||
filename = path.joinpath(path.cwd(), "data.nix")
|
||||
self.nix_file = nix.File.open(
|
||||
str(filename), nix.FileMode.Overwrite
|
||||
)
|
||||
|
||||
def create_actions(self):
|
||||
icon_path = str(rsrc_files("pyrelacs.icons").joinpath("exit.png"))
|
||||
self._rlx_exitaction = QAction(QIcon(":icons/exit.png"), "Exit", self)
|
||||
self._rlx_exitaction = QAction(QIcon(str(path.joinpath(_root, "icons/exit.png"))), "Exit", self)
|
||||
self._rlx_exitaction.setStatusTip("Close relacs")
|
||||
self._rlx_exitaction.setShortcut(QKeySequence("Alt+q"))
|
||||
self._rlx_exitaction.triggered.connect(self.on_exit)
|
||||
|
||||
self._rlx_aboutaction = QAction("about")
|
||||
self._rlx_aboutaction.setStatusTip("Show about dialog")
|
||||
self._rlx_aboutaction.setEnabled(True)
|
||||
self._rlx_aboutaction.triggered.connect(self.on_about)
|
||||
|
||||
# icon_path = str(rsrc_files("pyrelacs.icons").joinpath("connect.png"))
|
||||
self._daq_connectaction = QAction(QIcon(":/icons/connect.png"), "Connect DAQ", self)
|
||||
self._daq_connectaction = QAction(QIcon(str(path.joinpath(_root, "icons/connect.png"))), "Connect DAQ", self)
|
||||
self._daq_connectaction.setStatusTip("Connect to daq device")
|
||||
# self._daq_connectaction.setShortcut(QKeySequence("Alt+d"))
|
||||
self._daq_connectaction.triggered.connect(self.connect_dac)
|
||||
|
||||
icon_path = str(rsrc_files("pyrelacs.icons").joinpath("disconnect.png"))
|
||||
self._daq_disconnectaction = QAction(QIcon(icon_path), "Disconnect DAQ", self)
|
||||
self._daq_disconnectaction = QAction(QIcon(str(path.joinpath(_root, "icons/disconnect.png"))), "Disconnect DAQ", self)
|
||||
self._daq_disconnectaction.setStatusTip("Disconnect the DAQ device")
|
||||
# self._daq_connectaction.setShortcut(QKeySequence("Alt+d"))
|
||||
self._daq_disconnectaction.triggered.connect(self.disconnect_dac)
|
||||
|
||||
# icon_path = str(rsrc_files("pyrelacs.icons").joinpath("calibration.png"))
|
||||
self._daq_calibaction = QAction(QIcon(icon_path), "Plot calibration", self)
|
||||
self._daq_calibaction = QAction(QIcon(str(path.joinpath(_root, "icons/calibration.png"))), "Plot calibration", self)
|
||||
self._daq_calibaction.setStatusTip("Calibrate the attenuator device")
|
||||
# self._daq_calibaction.setShortcut(QKeySequence("Alt+d"))
|
||||
self._daq_calibaction.triggered.connect(self.plot_calibration)
|
||||
@ -96,6 +99,7 @@ class PyRelacs(QMainWindow):
|
||||
menu = self.menuBar()
|
||||
file_menu = menu.addMenu("&File")
|
||||
file_menu.addAction(self._rlx_exitaction)
|
||||
file_menu.addAction(self._rlx_aboutaction)
|
||||
|
||||
device_menu = menu.addMenu("&DAQ")
|
||||
device_menu.addAction(self._daq_connectaction)
|
||||
@ -254,6 +258,10 @@ class PyRelacs(QMainWindow):
|
||||
print("exit button!")
|
||||
self.close()
|
||||
|
||||
def on_about(self, e):
|
||||
about = AboutDialog(self)
|
||||
about.show()
|
||||
|
||||
def print_output(self, s):
|
||||
print(s)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user