1
0

main.py 1018 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env python3
  2. from nice_gui import ui
  3. from datetime import datetime
  4. from matplotlib import pyplot as plt
  5. with ui.card():
  6. ui.label('Rows and columns', 'h5')
  7. with ui.row():
  8. ui.label('A')
  9. ui.label('B')
  10. with ui.column():
  11. ui.label('C1')
  12. ui.label('C2')
  13. ui.label('C3')
  14. with ui.card():
  15. ui.label('Timer', 'h5')
  16. time = ui.label()
  17. ui.timer(0.1, lambda: time.set_text(datetime.now().strftime("%X")))
  18. with ui.card():
  19. ui.label('Interactive elements', 'h5')
  20. ui.button('Click me!', on_click=lambda: output.set_text('Click'))
  21. output = ui.label()
  22. with ui.card():
  23. ui.label('Matplotlib', 'h5')
  24. with ui.plot(close=False) as plot:
  25. plt.title('Some plot')
  26. plt.plot(range(10), [x**2 for x in range(10)])
  27. def update_plot():
  28. plt.title('Some plot with a second curve')
  29. plt.plot(range(10), [100 - x**2 for x in range(10)])
  30. plot.update()
  31. ui.timer(3.0, update_plot, once=True)
  32. ui.run()