浏览代码

add label for select element

Falko Schindler 3 年之前
父节点
当前提交
3022ad5008
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      nicegui/elements/select.py

+ 3 - 2
nicegui/elements/select.py

@@ -7,14 +7,15 @@ from .choice_element import ChoiceElement
 
 class Select(ChoiceElement):
 
-    def __init__(self, options: Union[List, Dict], *, value: Any = None, on_change: Optional[Callable] = None):
+    def __init__(self, options: Union[List, Dict], *,
+                 label: Optional[str] = None, value: Any = None, on_change: Optional[Callable] = None):
         """Dropdown Selection Element
 
         :param options: a list ['value1', ...] or dictionary `{'value1':'label1', ...}` specifying the options
         :param value: the inital value
         :param on_change: callback to execute when selection changes
         """
-        view = jp.QSelect(options=options, input=self.handle_change, temp=False)
+        view = jp.QSelect(options=options, label=label, input=self.handle_change, temp=False)
 
         super().__init__(view, options, value=value, on_change=on_change)