Explorar o código

update ui.input

Falko Schindler %!s(int64=2) %!d(string=hai) anos
pai
achega
4b45f865b7
Modificáronse 2 ficheiros con 7 adicións e 15 borrados
  1. 6 15
      nicegui/elements/input.py
  2. 1 0
      nicegui/ui.py

+ 6 - 15
nicegui/elements/old/input.py → nicegui/elements/input.py

@@ -1,14 +1,12 @@
 from typing import Callable, Optional
 
-import justpy as jp
+from .mixins.value_element import ValueElement
 
-from .string_element import StringElement
 
-
-class Input(StringElement):
+class Input(ValueElement):
 
     def __init__(self, label: str = None, *,
-                 placeholder: str = None, value: str = '', on_change: Optional[Callable] = None):
+                 placeholder: str = None, value: str = '', on_change: Optional[Callable] = None) -> None:
         """Text Input
 
         :param label: displayed label for the text input
@@ -16,13 +14,6 @@ class Input(StringElement):
         :param value: the current value of the text input
         :param on_change: callback to execute when the input is confirmed by leaving the focus
         """
-        view = jp.QInput(
-            label=label,
-            placeholder=placeholder,
-            value=value,
-            change=self.handle_change,
-            disable_input_event=True,
-            temp=False,
-        )
-
-        super().__init__(view, value=value, on_change=on_change)
+        super().__init__(tag='q-input', value=value, on_value_change=on_change)
+        self._props['label'] = label
+        self._props['placeholder'] = placeholder

+ 1 - 0
nicegui/ui.py

@@ -9,6 +9,7 @@ from .elements.column import Column as column
 from .elements.html import Html as html
 from .elements.icon import Icon as icon
 from .elements.image import Image as image
+from .elements.input import Input as input
 from .elements.joystick import Joystick as joystick
 from .elements.label import Label as label
 from .elements.link import Link as link