""" 页面跳转的demo样例
class User:
def __init__(self):
self.user: str = None
self.password: str = None
self.some_words = 'empty!'
self.clicked_pages = []
@ui.page('/second_page')
def second_page_load():
ui.label('this is the second page.')
cur_user.some_words = 'click second page.'
ui.button('go back.', on_click=lambda: ui.open(cur_user.clicked_pages[-2]))
cur_user.clicked_pages.append('/second_page')
@ui.page('/third_page')
def third_page_load():
ui.label('this is the third page.')
cur_user.some_words = 'click third page.'
ui.button('go back.', on_click=lambda: ui.open(cur_user.clicked_pages[-2]))
cur_user.clicked_pages.append('/second_page')
@ui.page('/')
def main_page_load():
ui.label('this is the first page.')
ui.label(f'{cur_user.some_words}').bind_text(cur_user, 'some_words')
with ui.card() as card_view: # 没认证成功, 则初始化登录界面;
ui.button('go page 2..', on_click=lambda: ui.open('/second_page'))
ui.button('go page 3..', on_click=lambda: ui.open('/third_page', new_tab=True))
cur_user.clicked_pages.append('/')
cur_user = User()
ui.run()
"""
""" 进度条控件
progressbar = ui.linear_progress(value=0)
def button_clicked():
step = 0.1
if progressbar.value + step <= 1:
progressbar.set_value(round(progressbar.value + step, 1))
ui.button('click', on_click=button_clicked)
ui.run()
"""