I'm trying to create a GUI for my python code. I ran into a problem, where i'd like to show a label with text "Please wait" and paralel with this i'd like to sleep my code for 1.25s. However, it is going into sleep without showing the label. It seems to me it somehow "skips" the .show()
Here is the snippet from the code:
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()