main.py 764 B

12345678910111213141516171819202122232425
  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 b: setattr(b, 'text', b.text + ' :)'))
  12. with ui.row() as row:
  13. row.checkbox('Let''s check...', on_change=lambda: row.label('Check!'))
  14. with ui.plot():
  15. plt.title('Some plot')
  16. plt.plot(range(10), [x**2 for x in range(10)])
  17. time = ui.label('Time:')
  18. def update_time():
  19. time.text = f'Time: {datetime.now().strftime("%H:%M:%S")}'
  20. ui.timer(1.0, update_time)