nice_gui.py 817 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import traceback
  2. import justpy as jp
  3. from icecream import ic
  4. pages = []
  5. def app():
  6. pages.append(jp.WebPage(delete_flag=False))
  7. def build():
  8. return pages[0]
  9. jp.justpy(build, start_server=False)
  10. return jp.app
  11. class Widget:
  12. def __init__(self):
  13. pass
  14. class Label(Widget):
  15. def __init__(self, text):
  16. super().__init__()
  17. p = jp.P(text=text, a=pages[0], classes='w-48 text-xl p-1 m-2')
  18. class Button(Widget):
  19. def __init__(self, text, on_click=None):
  20. super().__init__()
  21. def click(self, _):
  22. try:
  23. on_click(self)
  24. except:
  25. traceback.print_exc()
  26. d = jp.Div(text=text, a=pages[0], classes='w-48 text-xl m-2 p-1 bg-blue-700 text-white text-center')
  27. d.on('click', click)