pikapython/test/python/PikaUI/test_page.py

81 lines
1.6 KiB
Python
Raw Normal View History

import PikaUI as ui
from PikaStdLib import MemChecker as mem
2023-02-25 16:01:54 +08:00
class MainContainer(ui.Container):
2023-02-25 11:16:53 +08:00
def onclick_next(self, event):
print('Page1: onclick_next')
app.pageManager.enter(Page2())
mem.now()
2023-02-23 00:36:08 +08:00
def build(self):
return [
ui.Text(
text='Hello Page1',
align=ui.ALIGN.CENTER
),
ui.Button(
text='Next',
align=ui.ALIGN.CENTER,
pos=(0, 50),
height=30,
width=80,
onclick=self.onclick_next
)
]
2023-02-25 16:01:54 +08:00
class Page1(ui.Page):
def build(self):
return [
MainContainer(
width=300,
height=200,
pos=(0, 50)
),
ui.Text("Title")
]
2023-02-25 11:16:53 +08:00
2023-02-22 21:59:28 +08:00
class Page2(ui.Page):
2023-02-25 11:16:53 +08:00
def build(self):
2023-02-25 15:30:50 +08:00
return ui.Container(
2023-02-25 16:01:54 +08:00
width=400,
height=200,
2023-02-25 11:16:53 +08:00
pos=(0, 50)
).add(
ui.Text(
text='Hello Page2',
align=ui.ALIGN.CENTER
),
ui.Button(
text='Back',
align=ui.ALIGN.CENTER,
pos=(0, 50),
height=30,
width=80,
)
)
2023-02-22 21:59:28 +08:00
2023-02-25 16:01:54 +08:00
2023-02-22 21:59:28 +08:00
app = ui.App()
2023-02-25 15:30:50 +08:00
app.pageManager.enter(Page2())
app.timer.cb(0)
2023-03-09 20:45:55 +08:00
mem.now()
app.pageManager.enter(Page2())
app.timer.cb(0)
mem.now()
app.pageManager.back()
app.timer.cb(0)
mem.now()
2023-02-25 11:16:53 +08:00
2023-03-09 20:45:55 +08:00
gcdump()
2023-02-25 11:16:53 +08:00
# for i in range(100):
# app.pageManager.enter(Page2())
# app.timer.cb(0)
# mem.now()
# app.pageManager.back()
# app.timer.cb(0)
# mem.now()