json_editor_documentation.py 709 B

123456789101112131415161718192021222324
  1. from nicegui import ui
  2. from ...model import UiElementDocumentation
  3. class JsonEditorDocumentation(UiElementDocumentation, element=ui.json_editor):
  4. def main_demo(self) -> 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}'))