我正在嘗試為我的 python 代碼創(chuàng)建一個 GUI。我遇到了一個問題,我想顯示一個帶有文本“請稍候”的標(biāo)簽,與此并行我想讓我的代碼休眠 1.25 秒。但是,它在不顯示標(biāo)簽的情況下進(jìn)入睡眠狀態(tài)。在我看來,它以某種方式“跳過”了 .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
提交
取消