main.py 858 B

123456789101112131415161718192021222324252627
  1. from nice_gui import ui
  2. import matplotlib.pyplot as plt
  3. from datetime import datetime
  4. ui.label('Hello, Nice GUI!')
  5. with ui.row() as row:
  6. with row.column() as left:
  7. left.label('Add an element:')
  8. left.button('Button 1', on_click=lambda: left.label('Nice!'))
  9. with row.column() as right:
  10. right.label("Update itself:")
  11. right.button('Button 2', on_click=lambda e: setattr(e.sender, 'text', e.sender.text + ' :)'))
  12. with ui.card() as card:
  13. with card.plot():
  14. plt.title('Some plot')
  15. plt.plot(range(10), [x**2 for x in range(10)])
  16. with card.row() as row:
  17. row.checkbox('Let''s check...', on_change=lambda e: row.label('Check!' if e.checked else 'Uncheck.'))
  18. time = ui.label('Time:')
  19. def update_time():
  20. time.text = f'Time: {datetime.now().strftime("%H:%M:%S")}'
  21. ui.timer(1.0, update_time)