mirror of
https://github.com/bec-project/bec_widgets.git
synced 2026-11-12 12:34:07 +01:00
fix(widget_io): added option to set value of combobox by str
This commit is contained in:
1 parent
51f54ca22e
commit
1f2f4824bf
1 file changed
+5
-2
@@ -44,8 +44,11 @@ class ComboBoxHandler(WidgetHandler):
|
||||
def get_value(self, widget: QComboBox) -> int:
|
||||
return widget.currentIndex()
|
||||
|
||||
def set_value(self, widget: QComboBox, value: int) -> None:
|
||||
widget.setCurrentIndex(value)
|
||||
def set_value(self, widget: QComboBox, value: int | str) -> None:
|
||||
if isinstance(value, str):
|
||||
value = widget.findText(value)
|
||||
if isinstance(value, int):
|
||||
widget.setCurrentIndex(value)
|
||||
|
||||
|
||||
class TableWidgetHandler(WidgetHandler):
|
||||
|
||||
Reference in new issue
Block a user