forked from M-Labs/thermostat
Compare commits
14 Commits
c6fa3cdb80
...
38099d6d7b
Author | SHA1 | Date | |
---|---|---|---|
38099d6d7b | |||
9a00c2b8f2 | |||
99d095ebb9 | |||
54db579825 | |||
3144ea2c9d | |||
8b68ff7652 | |||
fb977982f8 | |||
e54e161e4e | |||
39bc3179cd | |||
ada95ec243 | |||
7b899eca2a | |||
c4ced31d18 | |||
0d9e8a3bf2 | |||
05c1a8547d |
@ -30,11 +30,6 @@ class CtrlPanel(QObject):
|
|||||||
self.trees_ui = trees_ui
|
self.trees_ui = trees_ui
|
||||||
self.NUM_CHANNELS = len(trees_ui)
|
self.NUM_CHANNELS = len(trees_ui)
|
||||||
|
|
||||||
def _set_value_with_lock(self, value):
|
|
||||||
if not self.opts.get("lock"):
|
|
||||||
self.setValue(value)
|
|
||||||
Parameter.set_value_with_lock = _set_value_with_lock
|
|
||||||
|
|
||||||
self.params = [
|
self.params = [
|
||||||
Parameter.create(
|
Parameter.create(
|
||||||
name=f"Thermostat Channel {ch} Parameters",
|
name=f"Thermostat Channel {ch} Parameters",
|
||||||
@ -52,31 +47,49 @@ class CtrlPanel(QObject):
|
|||||||
set_tree_label_tips(tree)
|
set_tree_label_tips(tree)
|
||||||
|
|
||||||
for ch, param in enumerate(self.params):
|
for ch, param in enumerate(self.params):
|
||||||
|
self.params[ch].setValue = self._setValue
|
||||||
param.sigTreeStateChanged.connect(sigTreeStateChanged_handle)
|
param.sigTreeStateChanged.connect(sigTreeStateChanged_handle)
|
||||||
|
|
||||||
for handle in sigActivated_handles[ch]:
|
for handle in sigActivated_handles[ch]:
|
||||||
param.child(*handle[0]).sigActivated.connect(handle[1])
|
param.child(*handle[0]).sigActivated.connect(handle[1])
|
||||||
|
|
||||||
def _indicate_usage(param, control_method):
|
param.child("output", "control_method").sigValueChanged.connect(
|
||||||
for item in param.child("i_set").items:
|
lambda param, value: param.child("i_set").setWritable(
|
||||||
is_constant_current = control_method == "constant_current"
|
value == "constant_current"
|
||||||
font = item.font(0)
|
)
|
||||||
font.setUnderline(is_constant_current)
|
)
|
||||||
font.setBold(is_constant_current)
|
|
||||||
item.setFont(0, font)
|
|
||||||
for item in param.child("target").items:
|
|
||||||
is_temperature_pid = control_method == "temperature_pid"
|
|
||||||
font = item.font(0)
|
|
||||||
font.setUnderline(is_temperature_pid)
|
|
||||||
font.setBold(is_temperature_pid)
|
|
||||||
item.setFont(0, font)
|
|
||||||
|
|
||||||
param.child("output", "control_method").sigValueChanged.connect(_indicate_usage)
|
param.child("output", "control_method").sigValueChanged.connect(
|
||||||
|
lambda param, value: param.child("target").show(
|
||||||
|
value == "temperature_pid"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
for item in param.child("output", "control_method").items:
|
def _setValue(self, value, blockSignal=None):
|
||||||
font = item.font(0)
|
"""
|
||||||
font.setBold(True)
|
Implement 'lock' mechanism for Parameter Type
|
||||||
item.setFont(0, font)
|
|
||||||
|
Modified from the source
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
if blockSignal is not None:
|
||||||
|
self.sigValueChanged.disconnect(blockSignal)
|
||||||
|
value = self._interpretValue(value)
|
||||||
|
if fn.eq(self.opts["value"], value):
|
||||||
|
return value
|
||||||
|
|
||||||
|
if "lock" in self.opts.keys():
|
||||||
|
if self.opts["lock"]:
|
||||||
|
return value
|
||||||
|
self.opts["value"] = value
|
||||||
|
self.sigValueChanged.emit(
|
||||||
|
self, value
|
||||||
|
) # value might change after signal is received by tree item
|
||||||
|
finally:
|
||||||
|
if blockSignal is not None:
|
||||||
|
self.sigValueChanged.connect(blockSignal)
|
||||||
|
|
||||||
|
return self.opts["value"]
|
||||||
|
|
||||||
def change_params_title(self, channel, path, title):
|
def change_params_title(self, channel, path, title):
|
||||||
self.params[channel].child(*path).setOpts(title=title)
|
self.params[channel].child(*path).setOpts(title=title)
|
||||||
@ -86,59 +99,57 @@ class CtrlPanel(QObject):
|
|||||||
for settings in pid_settings:
|
for settings in pid_settings:
|
||||||
channel = settings["channel"]
|
channel = settings["channel"]
|
||||||
with QSignalBlocker(self.params[channel]):
|
with QSignalBlocker(self.params[channel]):
|
||||||
self.params[channel].child("pid", "kp").set_value_with_lock(
|
self.params[channel].child("pid", "kp").setValue(
|
||||||
settings["parameters"]["kp"]
|
settings["parameters"]["kp"]
|
||||||
)
|
)
|
||||||
self.params[channel].child("pid", "ki").set_value_with_lock(
|
self.params[channel].child("pid", "ki").setValue(
|
||||||
settings["parameters"]["ki"]
|
settings["parameters"]["ki"]
|
||||||
)
|
)
|
||||||
self.params[channel].child("pid", "kd").set_value_with_lock(
|
self.params[channel].child("pid", "kd").setValue(
|
||||||
settings["parameters"]["kd"]
|
settings["parameters"]["kd"]
|
||||||
)
|
)
|
||||||
self.params[channel].child(
|
self.params[channel].child(
|
||||||
"pid", "pid_output_clamping", "output_min"
|
"pid", "pid_output_clamping", "output_min"
|
||||||
).set_value_with_lock(settings["parameters"]["output_min"])
|
).setValue(settings["parameters"]["output_min"])
|
||||||
self.params[channel].child(
|
self.params[channel].child(
|
||||||
"pid", "pid_output_clamping", "output_max"
|
"pid", "pid_output_clamping", "output_max"
|
||||||
).set_value_with_lock(settings["parameters"]["output_max"])
|
).setValue(settings["parameters"]["output_max"])
|
||||||
self.params[channel].child(
|
self.params[channel].child(
|
||||||
"output", "control_method", "target"
|
"output", "control_method", "target"
|
||||||
).set_value_with_lock(settings["target"])
|
).setValue(settings["target"])
|
||||||
|
|
||||||
@pyqtSlot("QVariantList")
|
@pyqtSlot("QVariantList")
|
||||||
def update_report(self, report_data):
|
def update_report(self, report_data):
|
||||||
for settings in report_data:
|
for settings in report_data:
|
||||||
channel = settings["channel"]
|
channel = settings["channel"]
|
||||||
with QSignalBlocker(self.params[channel]):
|
with QSignalBlocker(self.params[channel]):
|
||||||
self.params[channel].child(
|
self.params[channel].child("output", "control_method").setValue(
|
||||||
"output", "control_method"
|
|
||||||
).set_value_with_lock(
|
|
||||||
"temperature_pid" if settings["pid_engaged"] else "constant_current"
|
"temperature_pid" if settings["pid_engaged"] else "constant_current"
|
||||||
)
|
)
|
||||||
self.params[channel].child(
|
self.params[channel].child(
|
||||||
"output", "control_method", "i_set"
|
"output", "control_method", "i_set"
|
||||||
).set_value_with_lock(settings["i_set"])
|
).setValue(settings["i_set"])
|
||||||
if settings["temperature"] is not None:
|
if settings["temperature"] is not None:
|
||||||
self.params[channel].child(
|
self.params[channel].child("readings", "temperature").setValue(
|
||||||
"readings", "temperature"
|
settings["temperature"]
|
||||||
).set_value_with_lock(settings["temperature"])
|
)
|
||||||
if settings["tec_i"] is not None:
|
if settings["tec_i"] is not None:
|
||||||
self.params[channel].child(
|
self.params[channel].child("readings", "tec_i").setValue(
|
||||||
"readings", "tec_i"
|
settings["tec_i"]
|
||||||
).set_value_with_lock(settings["tec_i"])
|
)
|
||||||
|
|
||||||
@pyqtSlot("QVariantList")
|
@pyqtSlot("QVariantList")
|
||||||
def update_thermistor(self, sh_data):
|
def update_thermistor(self, sh_data):
|
||||||
for sh_param in sh_data:
|
for sh_param in sh_data:
|
||||||
channel = sh_param["channel"]
|
channel = sh_param["channel"]
|
||||||
with QSignalBlocker(self.params[channel]):
|
with QSignalBlocker(self.params[channel]):
|
||||||
self.params[channel].child("thermistor", "t0").set_value_with_lock(
|
self.params[channel].child("thermistor", "t0").setValue(
|
||||||
sh_param["params"]["t0"] - 273.15
|
sh_param["params"]["t0"] - 273.15
|
||||||
)
|
)
|
||||||
self.params[channel].child("thermistor", "r0").set_value_with_lock(
|
self.params[channel].child("thermistor", "r0").setValue(
|
||||||
sh_param["params"]["r0"]
|
sh_param["params"]["r0"]
|
||||||
)
|
)
|
||||||
self.params[channel].child("thermistor", "b").set_value_with_lock(
|
self.params[channel].child("thermistor", "b").setValue(
|
||||||
sh_param["params"]["b"]
|
sh_param["params"]["b"]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -149,15 +160,15 @@ class CtrlPanel(QObject):
|
|||||||
for pwm_params in pwm_data:
|
for pwm_params in pwm_data:
|
||||||
channel = pwm_params["channel"]
|
channel = pwm_params["channel"]
|
||||||
with QSignalBlocker(self.params[channel]):
|
with QSignalBlocker(self.params[channel]):
|
||||||
self.params[channel].child(
|
self.params[channel].child("output", "limits", "max_v").setValue(
|
||||||
"output", "limits", "max_v"
|
pwm_params["max_v"]["value"]
|
||||||
).set_value_with_lock(pwm_params["max_v"]["value"])
|
)
|
||||||
self.params[channel].child(
|
self.params[channel].child("output", "limits", "max_i_pos").setValue(
|
||||||
"output", "limits", "max_i_pos"
|
pwm_params["max_i_pos"]["value"]
|
||||||
).set_value_with_lock(pwm_params["max_i_pos"]["value"])
|
)
|
||||||
self.params[channel].child(
|
self.params[channel].child("output", "limits", "max_i_neg").setValue(
|
||||||
"output", "limits", "max_i_neg"
|
pwm_params["max_i_neg"]["value"]
|
||||||
).set_value_with_lock(pwm_params["max_i_neg"]["value"])
|
)
|
||||||
|
|
||||||
for limit in "max_i_pos", "max_i_neg", "max_v":
|
for limit in "max_i_pos", "max_i_neg", "max_v":
|
||||||
if pwm_params[limit]["value"] == 0.0:
|
if pwm_params[limit]["value"] == 0.0:
|
||||||
@ -169,6 +180,6 @@ class CtrlPanel(QObject):
|
|||||||
for postfilter_params in postfilter_data:
|
for postfilter_params in postfilter_data:
|
||||||
channel = postfilter_params["channel"]
|
channel = postfilter_params["channel"]
|
||||||
with QSignalBlocker(self.params[channel]):
|
with QSignalBlocker(self.params[channel]):
|
||||||
self.params[channel].child("postfilter", "rate").set_value_with_lock(
|
self.params[channel].child("thermistor", "rate").setValue(
|
||||||
postfilter_params["rate"]
|
postfilter_params["rate"]
|
||||||
)
|
)
|
||||||
|
@ -80,6 +80,7 @@
|
|||||||
"name": "target",
|
"name": "target",
|
||||||
"title": "Setpoint",
|
"title": "Setpoint",
|
||||||
"type": "float",
|
"type": "float",
|
||||||
|
"visible": false,
|
||||||
"value": 25,
|
"value": 25,
|
||||||
"step": 0.1,
|
"step": 0.1,
|
||||||
"limits": [
|
"limits": [
|
||||||
@ -88,6 +89,7 @@
|
|||||||
],
|
],
|
||||||
"format": "{value:.4f} {suffix}",
|
"format": "{value:.4f} {suffix}",
|
||||||
"suffix": "°C",
|
"suffix": "°C",
|
||||||
|
"regex": "(?P<number>[+-]?((((\\d+(\\.\\d*)?)|(\\d*\\.\\d+))([eE][+-]?\\d+)?)|((?i:nan)|(inf))))\\s*((?P<siPrefix>[uyzafpnµm kMGTPEZY]?)(?P<suffix>.*))?$",
|
||||||
"noUnitEditing": true,
|
"noUnitEditing": true,
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
"param": [
|
"param": [
|
||||||
@ -186,7 +188,7 @@
|
|||||||
"title": "Thermistor Settings",
|
"title": "Thermistor Settings",
|
||||||
"expanded": true,
|
"expanded": true,
|
||||||
"type": "group",
|
"type": "group",
|
||||||
"tip": "Parameters for the resistance to temperature conversion with the B-Parameter equation",
|
"tip": "Settings of the connected thermistor\n- Parameters for the resistance to temperature conversion (with the B-Parameter equation)\n- Settings for the 50/60 Hz filter with the thermistor",
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"name": "t0",
|
"name": "t0",
|
||||||
@ -200,6 +202,7 @@
|
|||||||
],
|
],
|
||||||
"format": "{value:.4f} {suffix}",
|
"format": "{value:.4f} {suffix}",
|
||||||
"suffix": "°C",
|
"suffix": "°C",
|
||||||
|
"regex": "(?P<number>[+-]?((((\\d+(\\.\\d*)?)|(\\d*\\.\\d+))([eE][+-]?\\d+)?)|((?i:nan)|(inf))))\\s*((?P<siPrefix>[uyzafpnµm kMGTPEZY]?)(?P<suffix>.*))?$",
|
||||||
"noUnitEditing": true,
|
"noUnitEditing": true,
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
"param": [
|
"param": [
|
||||||
@ -216,9 +219,7 @@
|
|||||||
"type": "float",
|
"type": "float",
|
||||||
"value": 10000,
|
"value": 10000,
|
||||||
"step": 100,
|
"step": 100,
|
||||||
"min": 0,
|
|
||||||
"siPrefix": true,
|
"siPrefix": true,
|
||||||
"pinSiPrefix": "k",
|
|
||||||
"suffix": "Ω",
|
"suffix": "Ω",
|
||||||
"noUnitEditing": true,
|
"noUnitEditing": true,
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
@ -247,18 +248,10 @@
|
|||||||
],
|
],
|
||||||
"tip": "The Beta Parameter",
|
"tip": "The Beta Parameter",
|
||||||
"lock": false
|
"lock": false
|
||||||
}
|
},
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "postfilter",
|
|
||||||
"title": "50/60 Hz filter settings",
|
|
||||||
"type": "group",
|
|
||||||
"tip": "Settings for the 50/60 Hz filter with the thermistor",
|
|
||||||
"children": [
|
|
||||||
{
|
{
|
||||||
"name": "rate",
|
"name": "rate",
|
||||||
"title": "Rejection",
|
"title": "50/60 Hz filter rejection",
|
||||||
"type": "list",
|
"type": "list",
|
||||||
"value": 16.67,
|
"value": 16.67,
|
||||||
"param": [
|
"param": [
|
||||||
@ -267,7 +260,7 @@
|
|||||||
"rate"
|
"rate"
|
||||||
],
|
],
|
||||||
"limits": {
|
"limits": {
|
||||||
"Off @ 10 Hz": null,
|
"Off": null,
|
||||||
"47 dB @ 10.41 Hz": 27.0,
|
"47 dB @ 10.41 Hz": 27.0,
|
||||||
"62 dB @ 10 Hz": 21.25,
|
"62 dB @ 10 Hz": 21.25,
|
||||||
"86 dB @ 9.1 Hz": 20.0,
|
"86 dB @ 9.1 Hz": 20.0,
|
||||||
@ -401,6 +394,7 @@
|
|||||||
"step": 0.1,
|
"step": 0.1,
|
||||||
"format": "{value:.4f} {suffix}",
|
"format": "{value:.4f} {suffix}",
|
||||||
"suffix": "°C",
|
"suffix": "°C",
|
||||||
|
"regex": "(?P<number>[+-]?((((\\d+(\\.\\d*)?)|(\\d*\\.\\d+))([eE][+-]?\\d+)?)|((?i:nan)|(inf))))\\s*((?P<siPrefix>[uyzafpnµm kMGTPEZY]?)(?P<suffix>.*))?$",
|
||||||
"noUnitEditing": true,
|
"noUnitEditing": true,
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
"pid_autotune": [
|
"pid_autotune": [
|
||||||
@ -438,7 +432,8 @@
|
|||||||
"value": 1.5,
|
"value": 1.5,
|
||||||
"step": 0.1,
|
"step": 0.1,
|
||||||
"format": "{value:.4f} {suffix}",
|
"format": "{value:.4f} {suffix}",
|
||||||
"suffix": "K",
|
"suffix": "°C",
|
||||||
|
"regex": "(?P<number>[+-]?((((\\d+(\\.\\d*)?)|(\\d*\\.\\d+))([eE][+-]?\\d+)?)|((?i:nan)|(inf))))\\s*((?P<siPrefix>[uyzafpnµm kMGTPEZY]?)(?P<suffix>.*))?$",
|
||||||
"noUnitEditing": true,
|
"noUnitEditing": true,
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
"pid_autotune": [
|
"pid_autotune": [
|
||||||
|
@ -1,18 +1,12 @@
|
|||||||
import re
|
|
||||||
|
|
||||||
from PyQt6.QtCore import QSignalBlocker
|
from PyQt6.QtCore import QSignalBlocker
|
||||||
from PyQt6.QtGui import QValidator
|
from PyQt6.QtGui import QValidator
|
||||||
|
|
||||||
from pyqtgraph import SpinBox
|
from pyqtgraph import SpinBox
|
||||||
import pyqtgraph.functions as fn
|
import pyqtgraph.functions as fn
|
||||||
from pyqtgraph.parametertree import registerParameterItemType
|
from pyqtgraph.parametertree.parameterTypes import (
|
||||||
from pyqtgraph.parametertree.parameterTypes import SimpleParameter, NumericParameterItem
|
SimpleParameter,
|
||||||
|
NumericParameterItem,
|
||||||
|
registerParameterItemType,
|
||||||
# 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>.*))?$"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -30,8 +24,9 @@ class UnitfulSpinBox(SpinBox):
|
|||||||
def __init__(self, parent=None, value=0.0, **kwargs):
|
def __init__(self, parent=None, value=0.0, **kwargs):
|
||||||
super().__init__(parent, value, **kwargs)
|
super().__init__(parent, value, **kwargs)
|
||||||
|
|
||||||
|
self._current_si_prefix = ""
|
||||||
self.lineEdit().cursorPositionChanged.connect(
|
self.lineEdit().cursorPositionChanged.connect(
|
||||||
self._editor_cursor_position_changed
|
self.editor_cursor_position_changed
|
||||||
)
|
)
|
||||||
|
|
||||||
def validate(self, strn, pos):
|
def validate(self, strn, pos):
|
||||||
@ -39,36 +34,31 @@ class UnitfulSpinBox(SpinBox):
|
|||||||
|
|
||||||
if self.opts.get("noUnitEditing") is True:
|
if self.opts.get("noUnitEditing") is True:
|
||||||
suffix = self.opts["suffix"]
|
suffix = self.opts["suffix"]
|
||||||
pinned_si_prefix = self.opts.get("pinSiPrefix")
|
|
||||||
|
|
||||||
suffix_edited = not strn.endswith(suffix)
|
# When the unit is edited / removed
|
||||||
pinned_si_prefix_edited = (
|
if not (
|
||||||
pinned_si_prefix is not None
|
strn.endswith(suffix)
|
||||||
and not strn.removesuffix(suffix).endswith(pinned_si_prefix)
|
and strn.removesuffix(suffix).endswith(self._current_si_prefix)
|
||||||
)
|
):
|
||||||
|
# Then the input is invalid instead of incomplete, reject this change
|
||||||
if suffix_edited or pinned_si_prefix_edited:
|
|
||||||
ret = QValidator.State.Invalid
|
ret = QValidator.State.Invalid
|
||||||
|
|
||||||
return ret, strn, pos
|
return ret, strn, pos
|
||||||
|
|
||||||
def _editor_cursor_position_changed(self, oldpos, newpos):
|
def editor_cursor_position_changed(self, oldpos, newpos):
|
||||||
# Called on cursor position change
|
"""
|
||||||
# Skips over the suffix and pinned SI prefix on cursor navigation if option
|
Modified from the original Qt C++ source,
|
||||||
# noUnitEditing is enabled.
|
QAbstractSpinBox::editorCursorPositionChanged
|
||||||
|
|
||||||
# Modified from the original Qt C++ source,
|
|
||||||
# QAbstractSpinBox::editorCursorPositionChanged.
|
|
||||||
# Their suffix is different than our suffix; there's no obvious way to set
|
|
||||||
# theirs here in the derived class since it is private.
|
|
||||||
|
|
||||||
|
Their suffix is different than our suffix; there's no obvious
|
||||||
|
way to set that one here.
|
||||||
|
"""
|
||||||
if self.opts.get("noUnitEditing") is True:
|
if self.opts.get("noUnitEditing") is True:
|
||||||
edit = self.lineEdit()
|
edit = self.lineEdit()
|
||||||
if edit.hasSelectedText():
|
if edit.hasSelectedText():
|
||||||
return # Allow for selecting units, for copy-and-paste
|
return # Allow for selecting units, for copy-and-paste
|
||||||
|
|
||||||
pinned_si_prefix = self.opts.get("pinSiPrefix") or ""
|
unit_len = len(self._current_si_prefix) + len(self.opts["suffix"])
|
||||||
unit_len = len(pinned_si_prefix) + len(self.opts["suffix"])
|
|
||||||
text_len = len(edit.text())
|
text_len = len(edit.text())
|
||||||
|
|
||||||
pos = -1
|
pos = -1
|
||||||
@ -91,30 +81,13 @@ class UnitfulSpinBox(SpinBox):
|
|||||||
|
|
||||||
super().setOpts(**opts)
|
super().setOpts(**opts)
|
||||||
|
|
||||||
def editingFinishedEvent(self):
|
|
||||||
# Modified from pyqtgraph.SpinBox.editingFinishedEvent source
|
|
||||||
|
|
||||||
new_text = self.lineEdit().text()
|
|
||||||
if new_text == self.lastText:
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
val = self.interpret()
|
|
||||||
except Exception:
|
|
||||||
return
|
|
||||||
|
|
||||||
if val is False:
|
|
||||||
return
|
|
||||||
if val == self.val:
|
|
||||||
self.updateText() # still update text so that values are reformatted pretty-like
|
|
||||||
return
|
|
||||||
self.setValue(val, delaySignal=False) ## allow text update so that values are reformatted pretty-like
|
|
||||||
|
|
||||||
def formatText(self, prev=None):
|
def formatText(self, prev=None):
|
||||||
"""
|
"""
|
||||||
In addition to pyqtgraph.SpinBox's formatting, incorporate the
|
Implement 'pinSiPrefix' mechanism for pyqtgraph.SpinBox, where
|
||||||
'pinSiPrefix' mechanism, where SI prefixes could be fixed.
|
SI prefixes could be pinned down.
|
||||||
|
|
||||||
|
Code modified from the PyQtGraph source
|
||||||
"""
|
"""
|
||||||
# Code modified from the PyQtGraph source
|
|
||||||
|
|
||||||
# get the number of decimal places to print
|
# get the number of decimal places to print
|
||||||
decimals = self.opts['decimals']
|
decimals = self.opts['decimals']
|
||||||
@ -136,6 +109,7 @@ class UnitfulSpinBox(SpinBox):
|
|||||||
else:
|
else:
|
||||||
(s, p) = fn.siScale(val)
|
(s, p) = fn.siScale(val)
|
||||||
parts = {'value': val, 'suffix': suffix, 'decimals': decimals, 'siPrefix': p, 'scaledValue': s*val, 'prefix':prefix}
|
parts = {'value': val, 'suffix': suffix, 'decimals': decimals, 'siPrefix': p, 'scaledValue': s*val, 'prefix':prefix}
|
||||||
|
self._current_si_prefix = p
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# no SI prefix /suffix requested; scale is 1
|
# no SI prefix /suffix requested; scale is 1
|
||||||
|
Loading…
Reference in New Issue
Block a user