5

Following Python Qgis cookbook, qgis doc and other usefull docs, I succesfully installed and configure the debugger for pluggin as "hello world". But, in the case of specific form, based on python script and Qt .ui files, I cannot figure out how to debug with the Pydev debug server.

I did :

  • run the debug server and the qgis plugin
  • set the python file path on Qgis
  • set the python file path on Pydev project,
  • set a breakpoint on def formOpen(): function
  • open the form under Qgis

The debugger never stop on the breakpoint. enter image description here

2
+50

For debug a QGIS plugins using your configuration and IDE the steps for eclipse projec are:

try:
    sys.path.append("D:/eclipse/plugins/org.python.pydev_5.9.2.201708151115/pysrc")
except:
    pass
  • In your other class need import pydev:
try:
    import sys
    from pydevd import *
except:
    None
  • For put a break point you need put the first time settrace() for stop the code in this class

And for example in a Load-QSS Plugin I'm stopping the code when open a main form:

enter image description here

Note that I have put a settrace () before calling this method, this way if you will recognize the next breakpoint

You can show some functional QGIS plugins using this configuration in my Github account

  • thanks for your reply but did you read the question, it's about python Form ? – Hugo Roussaffa - GeoDatup Oct 10 '17 at 8:47
  • the steps are the same, regardless of whether it's a form, dialog, etc. – Fran Raga Oct 10 '17 at 8:49
  • make sure that you put a settrace() before calling your function and that PyDev is imported... – Fran Raga Oct 10 '17 at 8:54
  • 1
    whaoou ! you give me the answer. I define a new function called initDebugForm in which I use settrace() method, then call my formOpen function. Under Qgis layer properties define the function name to initDebugForm, and when I open the form, the debugger stop on my breackpoint. thank you so much ! – Hugo Roussaffa - GeoDatup Oct 10 '17 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.