I am working on a small web crawler project for coursework using PyQt. I am trying to do a very simple thing - when a button is clicked the crawler starts running, I want to disable the button until the run is completed. However, for some reason, the button only gets disabled after the crawler is done and then is immediately re-enabled.
Here is my code:
def run_crawler_btn_clicked(self):
self.ShowPubsBtn.setEnabled(False)
self.RunCrawlerBtn.setEnabled(False)
self.RunCrawlerBtn.setText("Crawling nauka.offnews.bg...")
BASE_URL = 'https://nauka.offnews.bg'
crawler = Crawler(BASE_URL)
crawler.run()
self.RunCrawlerBtn.setEnabled(True)
self.ShowPubsBtn.setEnabled(True)
self.RunCrawlerBtn.setText("Crawl nauka.offnews.bg")
I suspect it is something related to slots and signals, but I couldn't put my finger on it.
I was also looking into QueuedConnection vs Direct Connection, but it should be queued in my case by default.
Any guidance on this issue will be greatly appreciated!