我正在尝试为我的 python 代码创建一个 GUI。我遇到了一个问题,我想显示一个带有文本“请稍候”的标签,与此并行我想让我的代码休眠 1.25 秒。但是,它在不显示标签的情况下进入睡眠状态。在我看来,它以某种方式“跳过”了 .show()这是代码的片段:def status_check(self): self.varakozas.setText("Please wait...") self.varakozas.show() time.sleep(1.25) sudoPassword = self.sudopassword.text() command = "some command" passtmeg = "echo '"+sudoPassword+"' | sudo -S "+command line = subprocess.Popen(["bash", "-c", passtmeg],stdout=subprocess.PIPE,shell=True) status_of = str(line.communicate()[0]) status_of_to_log = status_of.translate({ord(translate_table): "" for translate_table in "'b"}) logging.info('Status: '+ status_of_to_log[:-2]) if ("xy" in status_of) or ("Starting" in status_of): self._status.setText("xy is running") self.varakozas.hide() else: self._status.setText("xy is stopped") self.varakozas.hide()
添加回答
举报
0/150
提交
取消