Add help and about
This commit is contained in:
parent
c7340639ff
commit
adffbd6dbd
@ -3,7 +3,7 @@ from PyQt6.QtCore import Qt, QTimer
|
||||
from PyQt6.QtWidgets import QMainWindow, QWidget, QHBoxLayout, QLabel, QStatusBar, QFileDialog, \
|
||||
QVBoxLayout
|
||||
from PyQt6.QtWidgets import QToolBox, QTabWidget
|
||||
from PyQt6.QtGui import QIcon, QPixmap
|
||||
from PyQt6.QtGui import QIcon, QPixmap, QAction, QKeySequence
|
||||
from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QMessageBox
|
||||
|
||||
from ..resources import get_resource_path
|
||||
@ -33,10 +33,8 @@ from cpdctrl.measurement import measure
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
"""
|
||||
MainWindow
|
||||
|
||||
Args:
|
||||
QMainWindow (QMainWindow): Inheritance
|
||||
The main window of the app.
|
||||
Contains most logic as well as measurement functionality with live updates.
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
@ -98,6 +96,23 @@ class MainWindow(QMainWindow):
|
||||
|
||||
self.set_status("Ready")
|
||||
|
||||
# add qt actions that open help and about dialog
|
||||
self.a_open_help = QAction(text="Help", parent=self)
|
||||
self.a_open_help.setIcon(QIcon.fromTheme(QIcon.ThemeIcon.HelpFaq))
|
||||
self.a_open_help.setShortcut(QKeySequence("F1"))
|
||||
self.a_open_help.triggered.connect(lambda: self.app_open_help())
|
||||
|
||||
self.a_open_about = QAction(text="About", parent=self)
|
||||
self.a_open_about.setIcon(QIcon.fromTheme(QIcon.ThemeIcon.HelpAbout))
|
||||
self.a_open_about.triggered.connect(lambda: self.app_open_about())
|
||||
|
||||
self.topbar.addAction(self.a_open_help)
|
||||
self.topbar.addAction(self.a_open_about)
|
||||
self.menuBar().m_file.addAction(self.a_open_help)
|
||||
|
||||
# self.a_open_help.setShortcut(QKeySequence("F1"))
|
||||
|
||||
|
||||
def set_status(self, msg):
|
||||
self.statusBar().showMessage(msg)
|
||||
|
||||
@ -282,8 +297,8 @@ class MainWindow(QMainWindow):
|
||||
# print(data_queue.qsize(), "\n\n")
|
||||
current_data = self.data_queue.get(block=False)
|
||||
i, tval, vval, led_val = current_data
|
||||
print(f"Data {i:03}: {tval}s, {vval}V, {led_val}%")
|
||||
self.set_status(f"Data {i:03}: {tval}s, {vval}V, {led_val}%")
|
||||
# print(f"Data {i:03}: {tval}s, {vval}V, {led_val}%")
|
||||
self.set_status(f"Data {i:03}: {tval:.3f}s, {vval:.10f}V, {led_val:03}%")
|
||||
# update the plot
|
||||
self.w_plot.update_plot(tval, vval, led_val)
|
||||
else: # measurement might have stopped after max N or script end
|
||||
@ -331,7 +346,7 @@ class MainWindow(QMainWindow):
|
||||
buttons.accepted.connect(dialog.accept)
|
||||
dialog.setLayout(QVBoxLayout())
|
||||
# show the logo via a pixmap in a label
|
||||
img_path = get_resource_path("icons/logo2.svg")
|
||||
img_path = get_resource_path("icons/logo.svg")
|
||||
pixmap = QPixmap(img_path)
|
||||
pixmap = pixmap.scaled(128, 128, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation)
|
||||
# qt cant find the file
|
||||
@ -340,7 +355,17 @@ class MainWindow(QMainWindow):
|
||||
label.setAlignment(Qt.AlignmentFlag.AlignCenter) # center the image
|
||||
dialog.layout().addWidget(label)
|
||||
# show about.md
|
||||
dialog.layout().addWidget(MarkdownView("about2.md"))
|
||||
dialog.layout().addWidget(MarkdownView("about.md"))
|
||||
dialog.layout().addWidget(buttons)
|
||||
dialog.exec()
|
||||
|
||||
def app_open_help(self) -> None:
|
||||
dialog = QDialog()
|
||||
buttons = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok)
|
||||
buttons.accepted.connect(dialog.accept)
|
||||
dialog.setLayout(QVBoxLayout())
|
||||
# show help.md
|
||||
dialog.layout().addWidget(MarkdownView("troubleshooting.md"))
|
||||
dialog.layout().addWidget(buttons)
|
||||
dialog.exec()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user