Search code examples
pythonqtpysidepyside6

Why does my log message not execute first?


Lately I have been working on building a GUI for my python script with PySide6 (Qt). I added a button that executes my script when pushed:

def button_start_collecting(self):
        if not self.input_src.text():
            self.log_message("Please add the missing source path")
        if not self.input_dest.text():
            self.log_message("Please add the missing destination path")
        else:
            self.log_message("Starting to collect...")
            execute_pvt(self.dest, self.origin)
            self.log_message("The files and directories have been collected")

My problem is, that I expected the log message to appear on my log widget before the execution of the script itself, but it does not show up. Only after execution has finished, both log messages appear at the exact same time. It acts as if the code was structured as follows:

else:
           
            execute_pvt(self.dest, self.origin)
            self.log_message("Starting to collect...")
            self.log_message("The files and directories have been collected")

Does someone know how to fix this issue?


Solution

  • The problem could be resolved by executing execute_pvt() on a different thread.