Răsfoiți Sursa

checkbox example

Rodja Trappe 4 ani în urmă
părinte
comite
355e09bf79
2 a modificat fișierele cu 13 adăugiri și 0 ștergeri
  1. 7 0
      main.py
  2. 6 0
      nicegui/elements/checkbox.py

+ 7 - 0
main.py

@@ -88,6 +88,13 @@ with example(ui.button):
     ui.button('Button', on_click=button_increment)
     button_result = ui.label('pressed: 0')
 
+with example(ui.checkbox):
+
+    ui.checkbox('check me', on_change=lambda e: checkbox_state.set_text(e.value))
+    with ui.row():
+        ui.label('the checkbox is:')
+        checkbox_state = ui.label('False')
+
 with example(ui.input):
 
     ui.input(

+ 6 - 0
nicegui/elements/checkbox.py

@@ -9,7 +9,13 @@ class Checkbox(BoolElement):
                  value: bool = False,
                  design: str = '',
                  on_change: Callable = None):
+        """Checkbox Element
 
+        :param text: the label to display beside the checkbox
+        :param value: set to True if initally it should be checked; default is False
+        :param design: Quasar props to alter the appearance (see `their reference <https://quasar.dev/vue-components/checkbox>`_)
+        :param on_change: callback to execute when value changes
+        """
         view = jp.QCheckbox(text=text, input=self.handle_change)
 
         super().__init__(view, design, value, on_change)