main.py 666 B

12345678910111213141516171819202122
  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.plot():
  13. plt.title('Some plot')
  14. plt.plot(range(10), [x**2 for x in range(10)])
  15. time = ui.label('Time:')
  16. def update_time():
  17. time.text = f'Time: {datetime.now().strftime("%H:%M:%S")}'
  18. ui.timer(1.0, update_time)