量化交易之nicegui篇 - 页面跳转demo & 进度条控件

""" 页面跳转的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()
"""

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值