mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +02:00
fix(widget_io): added option to set value of combobox by str
This commit is contained in:
@ -44,8 +44,11 @@ class ComboBoxHandler(WidgetHandler):
|
|||||||
def get_value(self, widget: QComboBox) -> int:
|
def get_value(self, widget: QComboBox) -> int:
|
||||||
return widget.currentIndex()
|
return widget.currentIndex()
|
||||||
|
|
||||||
def set_value(self, widget: QComboBox, value: int) -> None:
|
def set_value(self, widget: QComboBox, value: int | str) -> None:
|
||||||
widget.setCurrentIndex(value)
|
if isinstance(value, str):
|
||||||
|
value = widget.findText(value)
|
||||||
|
if isinstance(value, int):
|
||||||
|
widget.setCurrentIndex(value)
|
||||||
|
|
||||||
|
|
||||||
class TableWidgetHandler(WidgetHandler):
|
class TableWidgetHandler(WidgetHandler):
|
||||||
|
Reference in New Issue
Block a user