json_editor_documentation.py 589 B

1234567891011121314151617181920212223242526
  1. from nicegui import ui
  2. from . import doc
  3. @doc.demo(ui.json_editor)
  4. def main_demo() -> None:
  5. json = {
  6. 'array': [1, 2, 3],
  7. 'boolean': True,
  8. 'color': '#82b92c',
  9. None: None,
  10. 'number': 123,
  11. 'object': {
  12. 'a': 'b',
  13. 'c': 'd',
  14. },
  15. 'time': 1575599819000,
  16. 'string': 'Hello World',
  17. }
  18. ui.json_editor({'content': {'json': json}},
  19. on_select=lambda e: ui.notify(f'Select: {e}'),
  20. on_change=lambda e: ui.notify(f'Change: {e}'))
  21. doc.reference(ui.json_editor)