Fix PyQT GUI Application Crashed While No Error Message Displayed: A Beginner Guide – PyQT Tutorial

By | December 18, 2019

When you are developing a pyqt gui application, you may encounter this kind of problem: The gui application crashed suddenly, however, there is no any error message is displayed. You can not find out where is wrong in your python script. To fix this problem, we will tell you how to do in this tutorial.

For example, we have created a thread in our python script, however, we have not imported python threading package.

#import threading

    def startSearch(self, dir, text, type='.php'):
        if self.search_thread:
            self.search_thread = None
        self.search_thread = threading.Thread(target=self.searchText, args=[dir, text, type])

You may can run your pyqt gui application, however, if you run startSearch() function, this gui application will crash and no any error message will be displayed.

How to fix this problem?

We can use code below at the beginning of your python script.

#import threading
import cgitb 
cgitb.enable(format = 'text')

Then you run your pyqt gui application again, you may find error message like this:fix pyqt gui application crashed while no error displayed

Then you can find what is wrong in your python script and fix it.