test_page.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. app.pageManager.enter(Page2())
  54. app.timer.cb(0)
  55. mem.now()
  56. app.pageManager.enter(Page2())
  57. app.timer.cb(0)
  58. mem.now()
  59. app.pageManager.back()
  60. app.timer.cb(0)
  61. mem.now()
  62. gcdump()
  63. # for i in range(100):
  64. # app.pageManager.enter(Page2())
  65. # app.timer.cb(0)
  66. # mem.now()
  67. # app.pageManager.back()
  68. # app.timer.cb(0)
  69. # mem.now()