PyQt GUI Operation Order

I have the following problem:

after clicking the button in the PyQt GUI, I have to do two things:

  • Update QTextBrowser Immediately
  • Run a method that will wait a while and activate some buttons after.

I get that 1 and 2 are executed at the same time, after a waiting period.

Code Part:

    #in the signals definition...
    signalUpdateProgressDialog = QtCore.pyqtSignal(str) # signal definition

    #in the connections definition...
    self.btnStopOpt.clicked.connect(self.clickStop1)
    self.btnStopOpt.clicked.connect(self.clickStop)

def updateProgressDialog(self, dialog):
    self.ProgressDialog.setHtml(dialog)

def clickStop1(self):
    # notify
    self.signalUpdateProgressDialog.emit('Message')

def clickStop(self):

    # shut down thread...

    print "Thread Stopped"

    time.sleep(5)
    # enable run button
    self.btnRun.setEnabled(True)

I tried everything in one clickStop method, I tried with and without signal allocation for updateProgress. Always, the GUI is updated only after a waiting period.

However, I ran into this problem before, I think I don’t understand how this works with the GUI. In general, how to get the required behavior: is the GUI updated when a line of code is executed?

+2
source share
1

GUI / , Qt. , , /.

Qt clickStop1(), Qt, . , clickStop() (, clicked .

, time.sleep(5), GUI , . .

clicked(), singleleshot QTimer. QTimer , . , ! , , QTimer.

+5

All Articles