Преглед изворни кода

minor documentation improvements

Rodja Trappe пре 3 година
родитељ
комит
64613e030b
2 измењених фајлова са 22 додато и 22 уклоњено
  1. 20 20
      main.py
  2. 2 2
      nicegui/elements/joystick.py

+ 20 - 20
main.py

@@ -109,26 +109,6 @@ with (example(binding)):
         ui.toggle({1: 'a', 2: 'b', 3: 'c'}).bind_value(demo.number)
         ui.toggle({1: 'a', 2: 'b', 3: 'c'}).bind_value(demo.number)
         ui.number().bind_value(demo.number)
         ui.number().bind_value(demo.number)
 
 
-lifecycle = '''### Lifecycle
-
-You can run a function or coroutine on startup as a parallel task by passing it to `ui.on_startup`.
-If NiceGui is shut down or restarted the tasks will be automatically canceled (for example when you make a code change).
-You can also execude cleanup code with `ui.on_shutdown`.
-'''
-with (example(lifecycle)):
-
-    count_label = ui.label('count: 0')
-    count = 0
-
-    async def update_count():
-        global count
-        while True:
-            count_label.text = f'count: {count}'
-            count += 1
-            await asyncio.sleep(1)
-
-    ui.on_startup(update_count())
-
 
 
 with example(ui.timer):
 with example(ui.timer):
     from datetime import datetime
     from datetime import datetime
@@ -275,3 +255,23 @@ with example(ui.joystick):
         on_move=lambda msg: coordinates.set_text(f'{msg.data.vector.x:.3f}, {msg.data.vector.y:.3f}'),
         on_move=lambda msg: coordinates.set_text(f'{msg.data.vector.x:.3f}, {msg.data.vector.y:.3f}'),
         on_end=lambda _: coordinates.set_text('0, 0'))
         on_end=lambda _: coordinates.set_text('0, 0'))
     coordinates = ui.label('0, 0')
     coordinates = ui.label('0, 0')
+
+lifecycle = '''### Lifecycle
+
+You can run a function or coroutine on startup as a parallel task by passing it to `ui.on_startup`.
+If NiceGui is shut down or restarted the tasks will be automatically canceled (for example when you make a code change).
+You can also execude cleanup code with `ui.on_shutdown`.
+'''
+with (example(lifecycle)):
+
+    count_label = ui.label('count: 0')
+    count = 0
+
+    async def update_count():
+        global count
+        while True:
+            count_label.text = f'count: {count}'
+            count += 1
+            await asyncio.sleep(1)
+
+    ui.on_startup(update_count())

+ 2 - 2
nicegui/elements/joystick.py

@@ -45,12 +45,12 @@ class Joystick(Element):
                  ):
                  ):
         """Joystick
         """Joystick
 
 
-        Create a joystick using nipple.js.
+        Create a joystick based on `nipple.js <https://yoannmoi.net/nipplejs/>`_.
 
 
         :param on_start: callback for when the user toches the joystick
         :param on_start: callback for when the user toches the joystick
         :param on_move: callback for when the user moves the joystick
         :param on_move: callback for when the user moves the joystick
         :param on_end: callback for when the user releases the joystick
         :param on_end: callback for when the user releases the joystick
-        :param options: arguments like `color` which should be passed to `nipple.js <https://github.com/yoannmoinet/nipplejs#options>`_
+        :param options: arguments like `color` which should be passed to the `underlying nipple.js library <https://github.com/yoannmoinet/nipplejs#options>`_
         """
         """
 
 
         super().__init__(JoystickView(on_start, on_move, on_end, **options))
         super().__init__(JoystickView(on_start, on_move, on_end, **options))