-1

I have a little GUI application I've written in PySide, which runs a few quick tests and then scrapes a good deal of information from a website, which takes around 3-4 minutes. After each test and prior to the scrape I have my program write to a log that is displayed on the UI (a QPlainTextEdit widget), however when the script launches, the UI freezes and doesn't update the log until the script has finished.

I have tried delaying (time.sleep) prior to the web scraping, but this still doesn't have the intended affect - it pauses the application, but still there is no log produces on screen until the scraping is done.

How do I ensure the text is displayed before each function is launched?

Groundhog
  • 55
  • 1
  • 6
  • You need threads, so that the fetching part isn't blocking the UI rendering part. – Burhan Khalid Jul 12 '15 at 09:53
  • Related: http://stackoverflow.com/a/21071865/1994235 This answer is for redirecting stdout/stderr to a text widget. You could adapt it to redirect your logging system to the text widget. Note, it assumes you will use threads as @BurhanKhalid has recommended (and I agree with him) and I would **not** recommend using `qApp.processEvents()`. – three_pineapples Jul 12 '15 at 11:46

1 Answers1

0

Call qApp.processEvents() immediately after emitting the log message and before entering the lengthy task, to ensure the UI is refreshed with the new log message.

codewarrior
  • 2,000
  • 14
  • 14