How to debug scripts launched from RunPythonScript (e.g. in custom button)?

Hello,

I created some custom buttons from which I launch Python scripts by calling something like:

_-RunPythonScript (MyScript.py)

The problem I have is that I cannot find a way to get the Rhino Python Editor attached to MyScript.py and use breakpoints, look at variables content, etc IF it is started from RunPythonScript. Does anybody know if it is possible to do so?

Not as far as I know… If you are simply calling the script files from a button but they are stored somewhere on your computer, why can’t you simply open them and run them from inside the editor when you need to debug?

–Mitch

That’s correct. The EditPythonScript command is what deals with setting up internal breakpoints and monitoring steps in the code. You wouldn’t want this debug information to be on all the time; it would slow down your scripts.

That’s probably what I will try do but it get much more complicated than that because what the button actually launches is a GUI like this one (anonymized to keep my client happy :blush: !)

This GUI keeps some internal states that are the result of some of the intermediate steps that must be feed to the later processing stages. The pain is that if I cannot look at the states of the variables in the GUI part, I have a hard time passing the right values (which can be geometrical objects) to the individual scripts (might need saving stuff to disk, writing logs just for that purpose, changing some module interfaces to add otherwise non-necessary input query capability, etc.).

I agree with Steve that we do not want the debug information to be ON all the time but being able to somehow attach the debugger to a running script or being able to start a script with a special switch like

_-RunPythonScript (MyScript.py, debug=True)

would be very helpful in situations like the one I just described.