test_page.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import PikaUI as ui
  2. from PikaStdLib import MemChecker as mem
  3. class MainContainer(ui.Container):
  4. def onclick_next(self, event):
  5. print('Page1: onclick_next')
  6. app.pageManager.enter(Page2())
  7. mem.now()
  8. def build(self):
  9. return [
  10. ui.Text(
  11. text='Hello Page1',
  12. align=ui.ALIGN.CENTER
  13. ),
  14. ui.Button(
  15. text='Next',
  16. align=ui.ALIGN.CENTER,
  17. pos=(0, 50),
  18. height=30,
  19. width=80,
  20. onclick=self.onclick_next
  21. )
  22. ]
  23. class Page1(ui.Page):
  24. def build(self):
  25. return [
  26. MainContainer(
  27. width=300,
  28. height=200,
  29. pos=(0, 50)
  30. ),
  31. ui.Text("Title")
  32. ]
  33. class Page2(ui.Page):
  34. def on_click_back(self, event):
  35. app.pageManager.back()
  36. mem.now()
  37. def build(self):
  38. return ui.Container(
  39. width=400,
  40. height=200,
  41. pos=(0, 50)
  42. ).add(
  43. ui.Text(
  44. text='Hello Page2',
  45. align=ui.ALIGN.CENTER
  46. ),
  47. ui.Button(
  48. text='Back',
  49. align=ui.ALIGN.CENTER,
  50. pos=(0, 50),
  51. height=30,
  52. width=80,
  53. onclick=self.on_click_back
  54. )
  55. )
  56. app = ui.App()
  57. app.pageManager.enter(Page1())
  58. app.timer.cb(0)
  59. mem.now()
  60. app.pageManager.enter(Page2())
  61. app.timer.cb(0)
  62. mem.now()
  63. app.pageManager.back()
  64. app.timer.cb(0)
  65. mem.now()
  66. # for i in range(100):
  67. # app.pageManager.enter(Page2())
  68. # app.timer.cb(0)
  69. # mem.now()
  70. # app.pageManager.back()
  71. # app.timer.cb(0)
  72. # mem.now()