From bffd216d4f41b4f400b7c9f4d841927f723cee3d Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Mon, 1 Jan 2024 12:34:09 +0100 Subject: [PATCH] axes label hints added; no need for return press --- src/gui_qt/_py/graph.py | 7 +++-- src/gui_qt/graphs/graphwindow.py | 53 +++++++++++++++++++++----------- src/resources/_ui/graph.ui | 18 +++++++++-- 3 files changed, 55 insertions(+), 23 deletions(-) diff --git a/src/gui_qt/_py/graph.py b/src/gui_qt/_py/graph.py index 62feba0..b54a751 100644 --- a/src/gui_qt/_py/graph.py +++ b/src/gui_qt/_py/graph.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'src/resources/_ui/graph.ui' +# Form implementation generated from reading ui file 'resources/_ui/graph.ui' # -# Created by: PyQt5 UI code generator 5.15.9 +# Created by: PyQt5 UI code generator 5.15.10 # # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again. Do not edit this file unless you know what you are doing. @@ -271,8 +271,11 @@ class Ui_GraphWindow(object): self.label_4.setText(_translate("GraphWindow", "---")) self.apply_button.setText(_translate("GraphWindow", "Apply")) self.label_5.setText(_translate("GraphWindow", "Title")) + self.title_lineedit.setToolTip(_translate("GraphWindow", "

Uses simple latex syntax, does not support italic/math environment. Sub-/superscripts need curly brackets.

Example: \\alpha^{123}

")) self.label_6.setText(_translate("GraphWindow", "X Axis")) + self.xaxis_linedit.setToolTip(_translate("GraphWindow", "

Uses simple latex syntax, does not support italic/math environment. Sub-/superscripts need curly brackets.

Example: \\alpha^{123}

")) self.label_7.setText(_translate("GraphWindow", "Y Axis")) + self.yaxis_linedit.setToolTip(_translate("GraphWindow", "

Uses simple latex syntax, does not support italic/math environment. Sub-/superscripts need curly brackets.

Example: \\alpha^{123}

")) self.checkBox.setText(_translate("GraphWindow", "Show legend")) from ..lib.graph_items import NMRPlotWidget from ..lib.listwidget import QListWidgetSelect diff --git a/src/gui_qt/graphs/graphwindow.py b/src/gui_qt/graphs/graphwindow.py index 2d8c67f..9369bf3 100644 --- a/src/gui_qt/graphs/graphwindow.py +++ b/src/gui_qt/graphs/graphwindow.py @@ -73,7 +73,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): self.scene = self.plotItem.scene() self.scene.sigMouseMoved.connect(self.move_mouse) - self.checkBox.stateChanged.connect(lambda x: self.legend.setVisible(x == QtCore.Qt.Checked)) + self.checkBox.stateChanged.connect(lambda x: self.legend.setVisible(x == QtCore.Qt.CheckState.Checked)) self.label_button.toggled.connect(lambda x: self.label_widget.setVisible(x)) self.limit_button.toggled.connect(lambda x: self.limit_widget.setVisible(x)) self.gridbutton.toggled.connect(lambda x: self.graphic.showGrid(x=x, y=x)) @@ -237,9 +237,13 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): self.error_plots[n] = err_plot list_item = QtWidgets.QListWidgetItem(real_plot.opts.get('name', '')) - list_item.setData(QtCore.Qt.UserRole, n) - list_item.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable) - list_item.setCheckState(QtCore.Qt.Checked) + list_item.setData(QtCore.Qt.ItemDataRole.UserRole, n) + list_item.setFlags( + QtCore.Qt.ItemFlag.ItemIsEnabled | + QtCore.Qt.ItemFlag.ItemIsSelectable | + QtCore.Qt.ItemFlag.ItemIsUserCheckable + ) + list_item.setCheckState(QtCore.Qt.CheckState.Checked) self.listWidget.addItem(list_item) toplevel += 1 @@ -271,7 +275,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): for i in range(self.listWidget.count()-1, 0, -1): item = self.listWidget.item(i) - if item.data(QtCore.Qt.UserRole) in name: + if item.data(QtCore.Qt.ItemDataRole.UserRole) in name: self.listWidget.takeItem(i) self.listWidget.blockSignals(False) @@ -465,24 +469,37 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): _y = pos.y() self.mousePositionChanged.emit(_x, _y) - @QtCore.pyqtSlot(name='on_title_lineedit_returnPressed') - @QtCore.pyqtSlot(name='on_xaxis_linedit_returnPressed') - @QtCore.pyqtSlot(name='on_yaxis_linedit_returnPressed') - def labels_changed(self): - label = {self.title_lineedit: 'title', self.xaxis_linedit: 'x', self.yaxis_linedit: 'y'}[self.sender()] - self.set_label(**{label: self.sender().text()}) + @QtCore.pyqtSlot(str, name='on_title_lineedit_textChanged') + @QtCore.pyqtSlot(str, name='on_xaxis_linedit_textChanged') + @QtCore.pyqtSlot(str, name='on_yaxis_linedit_textChanged') + def labels_changed(self, text: str): + label = { + self.title_lineedit: 'title', + self.xaxis_linedit: 'x', + self.yaxis_linedit: 'y', + }[self.sender()] + self.set_label(**{label: text}) - def set_label(self, x=None, y=None, title=None): + def set_label(self, x: str = None, y: str = None, title: str = None): if title is not None: - self.plotItem.setTitle(convert(title, old='tex', new='html'), **{'size': '10pt', 'color': self._fgcolor}) + self.plotItem.setTitle( + convert(title, old='tex', new='html'), + **{'size': '10pt', 'color': self._fgcolor}, + ) if x is not None: - self.plotItem.setLabel('bottom', convert(x, old='tex', new='html'), - **{'font-size': '10pt', 'color': self._fgcolor.name()}) + self.plotItem.setLabel( + 'bottom', + convert(x, old='tex', new='html'), + **{'font-size': '10pt', 'color': self._fgcolor.name()}, + ) if y is not None: - self.plotItem.setLabel('left', convert(y, old='tex', new='html'), - **{'font-size': '10pt', 'color': self._fgcolor.name()}) + self.plotItem.setLabel( + 'left', + convert(y, old='tex', new='html'), + **{'font-size': '10pt', 'color': self._fgcolor.name()}, + ) def set_logmode(self, xmode: bool = None, ymode: bool = None): r = self.ranges @@ -588,7 +605,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): for i in range(self.listWidget.count()): item = self.listWidget.item(i) - if item.data(QtCore.Qt.UserRole) == sid: + if item.data(QtCore.Qt.ItemDataRole.UserRole) == sid: item.setText(convert(name, old='tex', new='html')) self.listWidget.blockSignals(False) diff --git a/src/resources/_ui/graph.ui b/src/resources/_ui/graph.ui index a433365..d99e4fc 100644 --- a/src/resources/_ui/graph.ui +++ b/src/resources/_ui/graph.ui @@ -449,7 +449,11 @@ - + + + <html><head/><body><p>Uses simple latex syntax, does not support italic/math environment. Sub-/superscripts need curly brackets.<br/></p><p>Example: \alpha^{123}</p></body></html> + + @@ -475,7 +479,11 @@ - + + + <html><head/><body><p>Uses simple latex syntax, does not support italic/math environment. Sub-/superscripts need curly brackets.<br/></p><p>Example: \alpha^{123}</p></body></html> + + @@ -501,7 +509,11 @@ - + + + <html><head/><body><p>Uses simple latex syntax, does not support italic/math environment. Sub-/superscripts need curly brackets.<br/></p><p>Example: \alpha^{123}</p></body></html> + +