0

When I click a button, I want to open a new window (which contains a custom progress bar and then closes when it reaches 100%), and then in the background, while the progressbar is loading, I want to freeze the current GUI and only after the progress bar is closed, to continue the following operations on the GUI.

For exemple, on the GUI I have to make some kind of operations in the background, and show them only after the progress bar is closed. I have tried with time.sleep(5), but it also makes the progress bar process sleep and then after the seconds are done, they execute simultaneously.

def buttonClicked(self):
    self.progressBar= ProgressBar()
    self.progressBar.show()
    # Here I want to make operations in the background and display them only after progressBar is closed
    # I tried the following:
    time.sleep(5)
    self.taskToShowSomethingOnTheGUI() <-But they execute simultaneously after the 5 sec are done

I also tried other approaches with QThreads, but they don't seem to be capable to open a new window because they make the GUI freeze. I tried even to assign two different methods to a button to execute one after another, because I want the progress bar first, and then resume the other operations on the GUI.

Is there any ways to do this with threads? I found here that they used pyqt Slots. What is the proper way of opening a child dialog in a second thread in PyQt?. Which is the best way to do this?

  • Using signals and slots is the *only* reliable way to do it. Study the answer you linked, as it already provides what you're looking for. – musicamante Jun 20 '21 at 15:28

0 Answers0