0

I have a small PyQt app

...
def __init__ (self):
...
    self.btn_read_all.clicked.connect(self.get_all)
...
def get_all(self):
    self.statusbar.showMessage('Please Wait...')
    self.log('Text 1')
    self.setEnabled(False)

    self.tracker.read_all() # Vey slow function
    self.show_all()

    self.log('Text 2')
    self.setEnabled(True)
    self.statusbar.clearMessage()

My problem is that tracker.read_all runs very slow. And I don't want the user to have a possibility to click something while it's running. So I want to show him some message like "Please Wait" and disallow him click any items. I also don't want OS thinks that my app hangs and should be stopped. I want them just wait a little. So first I tried to disable QMainWindow before and re-enable after. But it doesn't work. You can see on the video (https://transfer.sh/ni0Zt/2018-05-08_18-49-59.mp4) that no changes are applied to UI while the whole function is finished even Text 1 and Text 2 appears at the same time.

So I have 2 questions:

  1. Why does it work like that? How can I fix that?
  2. Is there any special way to show the user that he should wait a little? Anything like sand-clock?
GhostKU
  • 1,898
  • 6
  • 23
  • 32
  • Similar to the question as I indicate that it is duplicated, you must do the slow task in another thread and update the GUI through signals. – eyllanesc May 08 '18 at 16:55
  • My problem is that `self.tracker.read_all()` for me is a blackbox, I can't add any progress signal in it. So if I have several different 'slow' functions (with different logic) I need to create a separate Worker Class and Thread for each of this function? Am I right? –  GhostKU May 09 '18 at 08:09

0 Answers0