def todolist(): tasks = [] put_html(r"""<h1 align="center"><strong>📝 To-Do List</strong></h1>""") with use_scope('tasks'): while True: task = input( type=TEXT, required=True, label='🏃 What are you going to do today?', placeholder='Add a task...', help_text='Try: "Write an article"', ) tasks.append(task) clear('tasks') put_table( tdata=[[ task, put_buttons(['Complete'], onclick=partial(complete_task, task=task, tasks=tasks)) ] for task in tasks], header=[ '🤩 Your Awesome Tasks', '✅ Have you completed your task?', ], )
def play(): word = get_word() # So'zdagi harflar word_letters = set(word) # Foydalanuvchi kiritgan harflar user_letters = '' print(f"Мен {len(word)} хонали сўз ўйладим. Топа оласизми?") # print(word) while word_letters: clear() print(display(user_letters,word)) if user_letters: print(f"Шу вақтгача топган ҳарфларингиз: {user_letters}") letter = input("Ҳарф киритинг: ").upper() if letter in user_letters: print("Бу ҳарфни аввал киритгансиз. Бошқа ҳарф киритинг.") continue elif letter in word: word_letters.remove(letter) print(f"{letter} ҳарфи тўғри.") else: print("Бундай ҳарф йўқ.") user_letters += letter print(f"Табриклайман! {word} сўзини {len(user_letters)} та уринишда топдингиз.")
def set_status(self, state: int) -> None: """ Args: state (int): 1 (running) 2 (not running) 3 (warning, stop unexpectedly) 4 (stop for update) 0 (hide) -1 (*state not changed) """ if state == -1: return clear() if state == 1: put_row( [ put_loading(color="success").style("--loading-border--"), None, put_text(t("Gui.Status.Running")), ], size="auto 2px 1fr", ) elif state == 2: put_row( [ put_loading(color="secondary").style("--loading-border-fill--"), None, put_text(t("Gui.Status.Inactive")), ], size="auto 2px 1fr", ) elif state == 3: put_row( [ put_loading(shape="grow", color="warning").style( "--loading-grow--" ), None, put_text(t("Gui.Status.Warning")), ], size="auto 2px 1fr", ) elif state == 4: put_row( [ put_loading(shape="grow", color="success").style( "--loading-grow--" ), None, put_text(t("Gui.Status.Updating")), ], size="auto 2px 1fr", )
def ui_alas(self, config_name: str) -> None: if config_name == self.alas_name: self.expand_menu() return self.init_aside(name=config_name) clear('content') self.alas_name = config_name self.alas = ProcessManager.get_manager(config_name) self.alas_config = AzurLaneConfig(config_name, '') self.state_switch.switch() self.alas_set_menu()
def add(): name = pin["AddAlas_name"] origin = pin["AddAlas_copyfrom"] if name not in alas_instance(): r = read_file(filepath_config(origin)) write_file(filepath_config(name), r) self.set_aside() self.active_button("aside", self.alas_name) close_popup() else: clear(s) put(name, origin) put_error(t("Gui.AddAlas.FileExist"), scope=s)
def init_menu(self, collapse_menu: bool = True, name: str = None) -> None: """ Call this in menu button callback function. Args: collapse_menu: collapse menu name: button name(label) to be highlight """ self.visible = True self.page = name self.task_handler.remove_pending_task() clear('content') if collapse_menu: self.collapse_menu() if name: self.active_button('menu', name)
def init_aside(self, expand_menu: bool = True, name: str = None) -> None: """ Call this in aside button callback function. Args: expand_menu: expand menu name: button name(label) to be highlight """ self.visible = True self.task_handler.remove_pending_task() clear('menu') if expand_menu: self.expand_menu() if name: self.active_button('aside', name) set_localstorage('aside', name)
def complete_task(choice: str, task: str, tasks): if choice == 'Complete': tasks.remove(task) clear('tasks') if tasks: put_table( tdata=[[ put_text(task), put_buttons(['Complete'], onclick=partial(complete_task, task=task, tasks=tasks)) ] for task in tasks], header=[ '🤩 Your Awesome Tasks', '✅ Have you completed your task?', ], scope='tasks', )
def alas_update_overiew_task(self) -> None: if not self.visible: return self.alas_config.load() self.alas_config.get_next_task() if len(self.alas_config.pending_task) >= 1: if self.alas.alive: running = self.alas_config.pending_task[:1] pending = self.alas_config.pending_task[1:] else: running = [] pending = self.alas_config.pending_task[:] else: running = [] pending = [] waiting = self.alas_config.waiting_task def put_task(func: Function): with use_scope(f"overview-task_{func.command}"): put_column( [ put_text(t(f"Task.{func.command}.name")).style( "--arg-title--"), put_text(str(func.next_run)).style("--arg-help--"), ], size="auto auto", ) put_button( label=t("Gui.Button.Setting"), onclick=lambda: self.alas_set_group(func.command), color="off", ) clear("running_tasks") clear("pending_tasks") clear("waiting_tasks") with use_scope("running_tasks"): if running: for task in running: put_task(task) else: put_text( t("Gui.Overview.NoTask")).style("--overview-notask-text--") with use_scope("pending_tasks"): if pending: for task in pending: put_task(task) else: put_text( t("Gui.Overview.NoTask")).style("--overview-notask-text--") with use_scope("waiting_tasks"): if waiting: for task in waiting: put_task(task) else: put_text( t("Gui.Overview.NoTask")).style("--overview-notask-text--")
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", )
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')
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")