Skip to content

Commit

Permalink
minor documentation improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rodja committed Jul 1, 2021
1 parent 4c947ae commit 64613e0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
40 changes: 20 additions & 20 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
4 changes: 2 additions & 2 deletions nicegui/elements/joystick.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ def __init__(self,
):
"""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_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 <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))

0 comments on commit 64613e0

Please sign in to comment.