forked from M-Labs/thermostat
ctrl_panel: Fix editing fields with unit "°C"
A faulty regular expression within PyQtGraph causes any Parameter with a suffix that doesn't begin with an alphanumeric character (as matched with \w) to act abnormally. For instance, entering "100 °C" into the input boxes gets interpreted as 10 °C. Patch the FLOAT_REGEX in PyQtGraph to simply match for any character in the suffix group.
This commit is contained in:
parent
3a0bb66212
commit
3c4bc4b50c
@ -1,3 +1,5 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
from PyQt6.QtCore import QSignalBlocker
|
from PyQt6.QtCore import QSignalBlocker
|
||||||
from PyQt6.QtGui import QValidator
|
from PyQt6.QtGui import QValidator
|
||||||
|
|
||||||
@ -7,6 +9,13 @@ from pyqtgraph.parametertree import registerParameterItemType
|
|||||||
from pyqtgraph.parametertree.parameterTypes import SimpleParameter, NumericParameterItem
|
from pyqtgraph.parametertree.parameterTypes import SimpleParameter, NumericParameterItem
|
||||||
|
|
||||||
|
|
||||||
|
# See https://github.com/pyqtgraph/pyqtgraph/issues/3115
|
||||||
|
fn.FLOAT_REGEX = re.compile(
|
||||||
|
r"(?P<number>[+-]?((((\d+(\.\d*)?)|(\d*\.\d+))([eE][+-]?\d+)?)|((?i:nan)|(inf))))\s*"
|
||||||
|
+ r"((?P<siPrefix>[u" + fn.SI_PREFIXES + r"]?)(?P<suffix>.*))?$"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class UnitfulSpinBox(SpinBox):
|
class UnitfulSpinBox(SpinBox):
|
||||||
"""
|
"""
|
||||||
Extension of PyQtGraph's SpinBox widget.
|
Extension of PyQtGraph's SpinBox widget.
|
||||||
|
Loading…
Reference in New Issue
Block a user