Esempio n. 1
0
 def u(state):
     if state == -1:
         return
     clear("remote_loading")
     clear("remote_state")
     clear("remote_info")
     if state in (1, 2):
         put_loading("grow", "success", "remote_loading").style(
             "--loading-grow--"
         )
         put_text(t("Gui.Remote.Running"), scope="remote_state")
         put_text(t("Gui.Remote.EntryPoint"), scope="remote_info")
         entrypoint = RemoteAccess.get_entry_point()
         if entrypoint:
             if State.electron:  # Prevent click into url in electron client
                 put_text(entrypoint, scope="remote_info").style(
                     "text-decoration-line: underline"
                 )
             else:
                 put_link(name=entrypoint, url=entrypoint, scope="remote_info")
         else:
             put_text("Loading...", scope="remote_info")
     elif state in (0, 3):
         put_loading("border", "secondary", "remote_loading").style(
             "--loading-border-fill--"
         )
         if (
             State.deploy_config.EnableRemoteAccess
             and State.deploy_config.Password
         ):
             put_text(t("Gui.Remote.NotRunning"), scope="remote_state")
         else:
             put_text(t("Gui.Remote.NotEnable"), scope="remote_state")
         put_text(t("Gui.Remote.ConfigureHint"), scope="remote_info")
         url = "http://app.azurlane.cloud" + (
             "" if State.deploy_config.Language.startswith("zh") else "/en.html"
         )
         put_html(
             f'<a href="{url}" target="_blank">{url}</a>', scope="remote_info"
         )
         if state == 3:
             put_warning(
                 t("Gui.Remote.SSHNotInstall"),
                 closable=False,
                 scope="remote_info",
             )
Esempio n. 2
0
def bmi_app():
    name=input("Whats Your name")
    put_text('Hi, welcome to our website', name)

    user_info=input_group("User_info",[input('Whats Your age?',name='age',type=FLOAT)
                                ])
    if user_info['age']<16:
        put_warning('Sorry You cant access our website')
    else:
        put_success('Congrats, You can use our website!')
        
        height = input("Input your height(cm):", type=FLOAT)
        weight = input("Input your weight(kg):", type=FLOAT)

        BMI = weight / (height / 100) ** 2

        top_status = [(16, 'Severely underweight'), (18.5, 'Underweight'),
                  (25, 'Normal'), (30, 'Overweight'),
                  (35, 'Moderately obese'), (float('inf'), 'Severely obese')]

        for top, status in top_status:
            if BMI <= top:
                put_text('Your BMI: %.1f. Category: %s' % (BMI, status))
                break
Esempio n. 3
0
    def dev_update(self) -> None:
        self.init_menu(name='Update')
        self.set_title(t("Gui.MenuDevelop.Update"))

        if not Setting.reload:
            put_warning(t("Gui.Update.DisabledWarn"))

        put_row(content=[
            put_scope('updater_loading'), None,
            put_scope('updater_state')
        ],
                size='auto .25rem 1fr')

        put_scope('updater_btn')
        put_scope('updater_info')

        def update_table():
            with use_scope('updater_info', clear=True):
                local_commit = updater.get_commit(short_sha1=True)
                upstream_commit = updater.get_commit(
                    f'origin/{updater.branch}', short_sha1=True)
                put_table([[t('Gui.Update.Local'), *local_commit],
                           [t('Gui.Update.Upstream'), *upstream_commit]],
                          header=[
                              '', 'SHA1',
                              t('Gui.Update.Author'),
                              t('Gui.Update.Time'),
                              t('Gui.Update.Message')
                          ])

        def u(state):
            if state == -1:
                return
            clear('updater_loading')
            clear('updater_state')
            clear('updater_btn')
            if state == 0:
                put_loading('border', 'secondary',
                            'updater_loading').style("--loading-border-fill--")
                put_text(t('Gui.Update.UpToDate'), scope='updater_state')
                put_button(t('Gui.Button.CheckUpdate'),
                           onclick=updater.check_update,
                           color='info',
                           scope='updater_btn')
                update_table()
            elif state == 1:
                put_loading('grow', 'success',
                            'updater_loading').style("--loading-grow--")
                put_text(t('Gui.Update.HaveUpdate'), scope='updater_state')
                put_button(t('Gui.Button.ClickToUpdate'),
                           onclick=updater.run_update,
                           color='success',
                           scope='updater_btn')
                update_table()
            elif state == 'checking':
                put_loading('border', 'primary',
                            'updater_loading').style("--loading-border--")
                put_text(t('Gui.Update.UpdateChecking'), scope='updater_state')
            elif state == 'failed':
                put_loading('grow', 'danger',
                            'updater_loading').style("--loading-grow--")
                put_text(t('Gui.Update.UpdateFailed'), scope='updater_state')
                put_button(t('Gui.Button.RetryUpdate'),
                           onclick=updater.run_update,
                           color='primary',
                           scope='updater_btn')
            elif state == 'start':
                put_loading('border', 'primary',
                            'updater_loading').style("--loading-border--")
                put_text(t('Gui.Update.UpdateStart'), scope='updater_state')
                put_button(t('Gui.Button.CancelUpdate'),
                           onclick=updater.cancel,
                           color='danger',
                           scope='updater_btn')
            elif state == 'wait':
                put_loading('border', 'primary',
                            'updater_loading').style("--loading-border--")
                put_text(t('Gui.Update.UpdateWait'), scope='updater_state')
                put_button(t('Gui.Button.CancelUpdate'),
                           onclick=updater.cancel,
                           color='danger',
                           scope='updater_btn')
            elif state == 'run update':
                put_loading('border', 'primary',
                            'updater_loading').style("--loading-border--")
                put_text(t('Gui.Update.UpdateRun'), scope='updater_state')
                put_button(t('Gui.Button.CancelUpdate'),
                           onclick=updater.cancel,
                           color='danger',
                           scope='updater_btn',
                           disabled=True)
            elif state == 'reload':
                put_loading('grow', 'success',
                            'updater_loading').style("--loading-grow--")
                put_text(t('Gui.Update.UpdateSuccess'), scope='updater_state')
                update_table()
            elif state == 'finish':
                put_loading('grow', 'success',
                            'updater_loading').style("--loading-grow--")
                put_text(t('Gui.Update.UpdateFinish'), scope='updater_state')
                update_table()
            elif state == 'cancel':
                put_loading('border', 'danger',
                            'updater_loading').style("--loading-border--")
                put_text(t('Gui.Update.UpdateCancel'), scope='updater_state')
                put_button(t('Gui.Button.CancelUpdate'),
                           onclick=updater.cancel,
                           color='danger',
                           scope='updater_btn',
                           disabled=True)
            else:
                put_text("Something went wrong, please contact develops",
                         scope='updater_state')
                put_text(f"state: {state}", scope='updater_state')

        updater_switch = Switch(status=u,
                                get_state=lambda: updater.state,
                                name='updater')

        update_table()
        self.task_handler.add(updater_switch.g(),
                              delay=0.5,
                              pending_delete=True)

        updater.check_update()
Esempio n. 4
0
    def dev_update(self) -> None:
        self.init_menu(name="Update")
        self.set_title(t("Gui.MenuDevelop.Update"))

        if not Setting.reload:
            put_warning(t("Gui.Update.DisabledWarn"))

        put_row(
            content=[
                put_scope("updater_loading"), None,
                put_scope("updater_state")
            ],
            size="auto .25rem 1fr",
        )

        put_scope("updater_btn")
        put_scope("updater_info")

        def update_table():
            with use_scope("updater_info", clear=True):
                local_commit = updater.get_commit(short_sha1=True)
                upstream_commit = updater.get_commit(
                    f"origin/{updater.branch}", short_sha1=True)
                put_table(
                    [
                        [t("Gui.Update.Local"), *local_commit],
                        [t("Gui.Update.Upstream"), *upstream_commit],
                    ],
                    header=[
                        "",
                        "SHA1",
                        t("Gui.Update.Author"),
                        t("Gui.Update.Time"),
                        t("Gui.Update.Message"),
                    ],
                )

        def u(state):
            if state == -1:
                return
            clear("updater_loading")
            clear("updater_state")
            clear("updater_btn")
            if state == 0:
                put_loading("border", "secondary",
                            "updater_loading").style("--loading-border-fill--")
                put_text(t("Gui.Update.UpToDate"), scope="updater_state")
                put_button(
                    t("Gui.Button.CheckUpdate"),
                    onclick=updater.check_update,
                    color="info",
                    scope="updater_btn",
                )
                update_table()
            elif state == 1:
                put_loading("grow", "success",
                            "updater_loading").style("--loading-grow--")
                put_text(t("Gui.Update.HaveUpdate"), scope="updater_state")
                put_button(
                    t("Gui.Button.ClickToUpdate"),
                    onclick=updater.run_update,
                    color="success",
                    scope="updater_btn",
                )
                update_table()
            elif state == "checking":
                put_loading("border", "primary",
                            "updater_loading").style("--loading-border--")
                put_text(t("Gui.Update.UpdateChecking"), scope="updater_state")
            elif state == "failed":
                put_loading("grow", "danger",
                            "updater_loading").style("--loading-grow--")
                put_text(t("Gui.Update.UpdateFailed"), scope="updater_state")
                put_button(
                    t("Gui.Button.RetryUpdate"),
                    onclick=updater.run_update,
                    color="primary",
                    scope="updater_btn",
                )
            elif state == "start":
                put_loading("border", "primary",
                            "updater_loading").style("--loading-border--")
                put_text(t("Gui.Update.UpdateStart"), scope="updater_state")
                put_button(
                    t("Gui.Button.CancelUpdate"),
                    onclick=updater.cancel,
                    color="danger",
                    scope="updater_btn",
                )
            elif state == "wait":
                put_loading("border", "primary",
                            "updater_loading").style("--loading-border--")
                put_text(t("Gui.Update.UpdateWait"), scope="updater_state")
                put_button(
                    t("Gui.Button.CancelUpdate"),
                    onclick=updater.cancel,
                    color="danger",
                    scope="updater_btn",
                )
            elif state == "run update":
                put_loading("border", "primary",
                            "updater_loading").style("--loading-border--")
                put_text(t("Gui.Update.UpdateRun"), scope="updater_state")
                put_button(
                    t("Gui.Button.CancelUpdate"),
                    onclick=updater.cancel,
                    color="danger",
                    scope="updater_btn",
                    disabled=True,
                )
            elif state == "reload":
                put_loading("grow", "success",
                            "updater_loading").style("--loading-grow--")
                put_text(t("Gui.Update.UpdateSuccess"), scope="updater_state")
                update_table()
            elif state == "finish":
                put_loading("grow", "success",
                            "updater_loading").style("--loading-grow--")
                put_text(t("Gui.Update.UpdateFinish"), scope="updater_state")
                update_table()
            elif state == "cancel":
                put_loading("border", "danger",
                            "updater_loading").style("--loading-border--")
                put_text(t("Gui.Update.UpdateCancel"), scope="updater_state")
                put_button(
                    t("Gui.Button.CancelUpdate"),
                    onclick=updater.cancel,
                    color="danger",
                    scope="updater_btn",
                    disabled=True,
                )
            else:
                put_text(
                    "Something went wrong, please contact develops",
                    scope="updater_state",
                )
                put_text(f"state: {state}", scope="updater_state")

        updater_switch = Switch(status=u,
                                get_state=lambda: updater.state,
                                name="updater")

        update_table()
        self.task_handler.add(updater_switch.g(),
                              delay=0.5,
                              pending_delete=True)

        updater.check_update()
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

import pywebio.output as out

out.put_info("Info message")
out.put_success("Success message")
out.put_warning("Warning message")
out.put_error("Error message")