Why does my log message not execute first?

Question:

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?

Asked By: PatrickRKa

||

Answers:

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

Answered By: PatrickRKa
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.