mirror of
https://github.com/nqrduck/nqrduck-spectrometer.git
synced 2024-11-09 20:40:02 +00:00
Fixed bug with widget creation.
This commit is contained in:
parent
a39b4a1bc7
commit
837524b69f
2 changed files with 18 additions and 3 deletions
|
@ -54,6 +54,7 @@ class BaseSpectrometerView(ModuleView):
|
||||||
setting_label.setMinimumWidth(200)
|
setting_label.setMinimumWidth(200)
|
||||||
|
|
||||||
edit_widget = setting.get_widget()
|
edit_widget = setting.get_widget()
|
||||||
|
logger.debug("Setting widget: %s", edit_widget)
|
||||||
|
|
||||||
# Add a icon that can be used as a tooltip
|
# Add a icon that can be used as a tooltip
|
||||||
if setting.description is not None:
|
if setting.description is not None:
|
||||||
|
|
|
@ -103,7 +103,8 @@ class BooleanSetting(Setting):
|
||||||
"""
|
"""
|
||||||
widget = QCheckBox()
|
widget = QCheckBox()
|
||||||
widget.setChecked(self.value)
|
widget.setChecked(self.value)
|
||||||
widget.stateChanged.connect(lambda x=widget, s=self: s.on_value_changed(x.text()))
|
widget.stateChanged.connect(lambda x=widget, s=self: s.on_value_changed(bool(x)))
|
||||||
|
return widget
|
||||||
|
|
||||||
class SelectionSetting(Setting):
|
class SelectionSetting(Setting):
|
||||||
""" A setting that is a selection from a list of options."""
|
""" A setting that is a selection from a list of options."""
|
||||||
|
@ -138,7 +139,7 @@ class SelectionSetting(Setting):
|
||||||
widget = QComboBox()
|
widget = QComboBox()
|
||||||
widget.addItems(self.options)
|
widget.addItems(self.options)
|
||||||
widget.setCurrentText(self.value)
|
widget.setCurrentText(self.value)
|
||||||
widget.currentTextChanged.connect(lambda x=widget, s=self: s.on_value_changed(x.text()))
|
widget.currentTextChanged.connect(lambda x=widget, s=self: s.on_value_changed(x))
|
||||||
return widget
|
return widget
|
||||||
|
|
||||||
class IPSetting(Setting):
|
class IPSetting(Setting):
|
||||||
|
@ -178,3 +179,16 @@ class StringSetting(Setting):
|
||||||
raise ValueError("Value must be a string")
|
raise ValueError("Value must be a string")
|
||||||
|
|
||||||
self.settings_changed.emit()
|
self.settings_changed.emit()
|
||||||
|
|
||||||
|
def get_widget(self):
|
||||||
|
"""Return a widget for the setting.
|
||||||
|
The default widget is simply a QLineEdit.
|
||||||
|
This method can be overwritten by subclasses to return a different widget.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
QLineEdit: A QLineEdit widget that can be used to change the setting.
|
||||||
|
"""
|
||||||
|
widget = QLineEdit(str(self.value))
|
||||||
|
widget.setMinimumWidth(100)
|
||||||
|
widget.editingFinished.connect(lambda x=widget, s=self: s.on_value_changed(x.text()))
|
||||||
|
return widget
|
Loading…
Reference in a new issue