Python – PyQt debugging in main loop

debuggingpyqtpython

Can I debug PyQt application when is main loop running ?
Pdb, NetBeans, PyDev, all "freeze" when sys.exit(app.exec_()) is executed.
I probably missing something obvious. Or what can be problem, please ?
I apologize for my "creepy" english. Thanks.

Best Answer

I'm assuming your main() function looks something like this:

def __name__ == '__main__':
    app = QtGui.QApplication(sys.argv)
    myapp = MyApplication()
    myapp.show()
    sys.exit(app.exec_())

If not, post some example code to help determine what coudl be wrong.

If that is what your code looks like, you can debug any part of you program using IDLE (included in Python install). Once in IDLE, goto Debug-->Debugger to turn DEBUGGING ON. Then open your .py file, and run it (F5). You can set breakpoints by right-clicking on any line in the file, and choosing Set Breakpoint.

Check this other SO question for more info and good links to alternative debuggers/IDEs:

Cleanest way to run/debug python programs in windows

Related Topic