test_page.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 build(self):
  35. return ui.Container(
  36. width=400,
  37. height=200,
  38. pos=(0, 50)
  39. ).add(
  40. ui.Text(
  41. text='Hello Page2',
  42. align=ui.ALIGN.CENTER
  43. ),
  44. ui.Button(
  45. text='Back',
  46. align=ui.ALIGN.CENTER,
  47. pos=(0, 50),
  48. height=30,
  49. width=80,
  50. )
  51. )
  52. app = ui.App()
  53. page1 = Page1()
  54. page1.add(page1.build())
  55. app.pageManager.enter(Page2())
  56. app.timer.cb(0)
  57. # mem.now()
  58. # app.pageManager.enter(Page2())
  59. # app.timer.cb(0)
  60. # mem.now()
  61. # app.pageManager.back()
  62. # app.timer.cb(0)
  63. # mem.now()
  64. # for i in range(100):
  65. # app.pageManager.enter(Page2())
  66. # app.timer.cb(0)
  67. # mem.now()
  68. # app.pageManager.back()
  69. # app.timer.cb(0)
  70. # mem.now()