From 38099d6d7b331ea9f5cb81a553d9c87f5026a34b Mon Sep 17 00:00:00 2001 From: atse Date: Tue, 30 Jul 2024 13:31:42 +0800 Subject: [PATCH] =?UTF-8?q?ctrl=5Fpanel:=20Fix=20editing=20fields=20with?= =?UTF-8?q?=20unit=20"=C2=B0C"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Use a custom regular expression for Parameters with this unit, which simply matches for any character in the suffix group. --- pytec/pytec/gui/view/param_tree.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pytec/pytec/gui/view/param_tree.json b/pytec/pytec/gui/view/param_tree.json index b3ac362..506f307 100644 --- a/pytec/pytec/gui/view/param_tree.json +++ b/pytec/pytec/gui/view/param_tree.json @@ -89,6 +89,7 @@ ], "format": "{value:.4f} {suffix}", "suffix": "°C", + "regex": "(?P[+-]?((((\\d+(\\.\\d*)?)|(\\d*\\.\\d+))([eE][+-]?\\d+)?)|((?i:nan)|(inf))))\\s*((?P[uyzafpnµm kMGTPEZY]?)(?P.*))?$", "noUnitEditing": true, "compactHeight": false, "param": [ @@ -201,6 +202,7 @@ ], "format": "{value:.4f} {suffix}", "suffix": "°C", + "regex": "(?P[+-]?((((\\d+(\\.\\d*)?)|(\\d*\\.\\d+))([eE][+-]?\\d+)?)|((?i:nan)|(inf))))\\s*((?P[uyzafpnµm kMGTPEZY]?)(?P.*))?$", "noUnitEditing": true, "compactHeight": false, "param": [ @@ -392,6 +394,7 @@ "step": 0.1, "format": "{value:.4f} {suffix}", "suffix": "°C", + "regex": "(?P[+-]?((((\\d+(\\.\\d*)?)|(\\d*\\.\\d+))([eE][+-]?\\d+)?)|((?i:nan)|(inf))))\\s*((?P[uyzafpnµm kMGTPEZY]?)(?P.*))?$", "noUnitEditing": true, "compactHeight": false, "pid_autotune": [ @@ -430,6 +433,7 @@ "step": 0.1, "format": "{value:.4f} {suffix}", "suffix": "°C", + "regex": "(?P[+-]?((((\\d+(\\.\\d*)?)|(\\d*\\.\\d+))([eE][+-]?\\d+)?)|((?i:nan)|(inf))))\\s*((?P[uyzafpnµm kMGTPEZY]?)(?P.*))?$", "noUnitEditing": true, "compactHeight": false, "pid_autotune": [