bugfixes-01012024 #197

Merged
dominik merged 7 commits from bugfixes-01012024 into master 2024-01-02 10:10:49 +00:00
3 changed files with 55 additions and 23 deletions
Showing only changes of commit bffd216d4f - Show all commits

View File

@ -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", "<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>"))
self.label_6.setText(_translate("GraphWindow", "X Axis"))
self.xaxis_linedit.setToolTip(_translate("GraphWindow", "<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>"))
self.label_7.setText(_translate("GraphWindow", "Y Axis"))
self.yaxis_linedit.setToolTip(_translate("GraphWindow", "<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>"))
self.checkBox.setText(_translate("GraphWindow", "Show legend"))
from ..lib.graph_items import NMRPlotWidget
from ..lib.listwidget import QListWidgetSelect

View File

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

View File

@ -449,7 +449,11 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="title_lineedit"/>
<widget class="QLineEdit" name="title_lineedit">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Uses simple latex syntax, does not support italic/math environment. Sub-/superscripts need curly brackets.&lt;br/&gt;&lt;/p&gt;&lt;p&gt;Example: \alpha^{123}&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
@ -475,7 +479,11 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="xaxis_linedit"/>
<widget class="QLineEdit" name="xaxis_linedit">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Uses simple latex syntax, does not support italic/math environment. Sub-/superscripts need curly brackets.&lt;br/&gt;&lt;/p&gt;&lt;p&gt;Example: \alpha^{123}&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
@ -501,7 +509,11 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="yaxis_linedit"/>
<widget class="QLineEdit" name="yaxis_linedit">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Uses simple latex syntax, does not support italic/math environment. Sub-/superscripts need curly brackets.&lt;br/&gt;&lt;/p&gt;&lt;p&gt;Example: \alpha^{123}&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>