فهرست منبع

documenting number, radio and select

Rodja Trappe 4 سال پیش
والد
کامیت
bc7c992cc3
4فایلهای تغییر یافته به همراه40 افزوده شده و 2 حذف شده
  1. 15 0
      main.py
  2. 10 1
      nicegui/elements/number.py
  3. 7 0
      nicegui/elements/radio.py
  4. 8 1
      nicegui/elements/select.py

+ 15 - 0
main.py

@@ -113,6 +113,21 @@ with example(ui.input):
     )
     result = ui.label('')
 
+with example(ui.number):
+    number_input = ui.number(label='Number', value=3.1415927, format='%.2f')
+    with ui.row():
+        ui.label('underlying value: ')
+        ui.label().bind_text_from(number_input.value)
+
+with example(ui.radio):
+    radio = ui.radio(options=[1, 2, 3], value=1, design='inline')
+    ui.radio(options={1: 'A', 2: 'B', 3: 'C'}, value=1, design='inline').bind_value(radio.value)
+
+with example(ui.select):
+    with ui.row():
+        select = ui.select(options=[1, 2, 3], value=1, design='inline')
+        ui.select(options={1: 'A', 2: 'B', 3: 'C'}, value=1, design='inline').bind_value(select.value)
+
 with example(ui.plot):
     from matplotlib import pyplot as plt
     import numpy as np

+ 10 - 1
nicegui/elements/number.py

@@ -12,8 +12,17 @@ class Number(FloatElement):
                  format: str = None,
                  on_change: Callable = None,
                  design: str = '',
-                 classes: str='',
+                 classes: str = '',
                  ):
+        """Number Input Element
+
+        :param label: display name for the input
+        :param placeholder: text to show if no value is entered
+        :param value: the inital value of the field
+        :param format: a string like '%.2f' to format the entered number before displaying
+        :param on_change: callback when the input is confirmed via leaving the focus
+        :param design: Quasar props to alter the appearance (see `their reference <https://quasar.dev/vue-components/input>`_)
+        """
 
         view = jp.QInput(
             type='number',

+ 7 - 0
nicegui/elements/radio.py

@@ -11,6 +11,13 @@ class Radio(ChoiceElement):
                  design: str = '',
                  classes: str = ''
                  ):
+        """Radio Selection Element
+
+        :param options: a list or dict specifying the options
+        :param value: the inital value
+        :param on_change: callback when selection changes
+        :param design: Quasar props to alter the appearance (see `their reference <https://quasar.dev/vue-components/radio>`_)
+        """
 
         view = jp.QOptionGroup(options=options, input=self.handle_change)
 

+ 8 - 1
nicegui/elements/select.py

@@ -9,8 +9,15 @@ class Select(ChoiceElement):
                  value: any = None,
                  on_change: Callable = None,
                  design: str = '',
-                 classes: str=''
+                 classes: str = ''
                  ):
+        """Dropdown Selection Element
+
+        :param options: a list or dict specifying the options
+        :param value: the inital value
+        :param on_change: callback when selection changes
+        :param design: Quasar props to alter the appearance (see `their reference <https://quasar.dev/vue-components/select>`_)
+        """
 
         view = jp.QSelect(options=options, input=self.handle_change)