views:

226

answers:

1

Hello. 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.

+1  A: 

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:

http://stackoverflow.com/questions/445595/cleanest-way-to-run-debug-python-programs-in-windows

jcoon
Thanks for link to another SO question - there accepted answer discusses winpdb + links to winpdb tutorial - it's all you need if you experience "freezing" of you main PyQt loop.
Victor Farazdagi