From 64613e030b4858902e786992016fb2a83998829b Mon Sep 17 00:00:00 2001 From: Rodja Trappe Date: Thu, 1 Jul 2021 06:04:59 +0200 Subject: [PATCH] minor documentation improvements --- main.py | 40 ++++++++++++++++++------------------ nicegui/elements/joystick.py | 4 ++-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/main.py b/main.py index 72a79bfd5..2ed8beecc 100755 --- a/main.py +++ b/main.py @@ -109,26 +109,6 @@ def __init__(self): ui.toggle({1: 'a', 2: 'b', 3: 'c'}).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): from datetime import datetime @@ -275,3 +255,23 @@ def button_increment(): 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')) 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()) diff --git a/nicegui/elements/joystick.py b/nicegui/elements/joystick.py index 0f1e3eb76..62cf3344d 100644 --- a/nicegui/elements/joystick.py +++ b/nicegui/elements/joystick.py @@ -45,12 +45,12 @@ def __init__(self, ): """Joystick - Create a joystick using nipple.js. + Create a joystick based on `nipple.js `_. :param on_start: callback for when the user toches 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 options: arguments like `color` which should be passed to `nipple.js `_ + :param options: arguments like `color` which should be passed to the `underlying nipple.js library `_ """ super().__init__(JoystickView(on_start, on_move, on_end, **options))