Python Debugger Setup & Example

This details how to setup and use the Python debugger.

To get the debugger the debug mode should be enabled before starting.

pbApplication := PBApplication new.
pbApplication settings serverDebugMode: true.
pbApplication start.
PBApplication uniqueInstance: pbApplication

Now make sure everything starts up OK.

PBApplication uniqueInstance

To check that the python process is running in the right folder.

import os

If there are errors it can be useful to stop the Python server link.

PBApplication stopAllInstances

PythonBridge uses the python exec() function to evaluate snippets. Breakpoints aren't supported directly in the exec() script, so must be placed in a function, e.g.:

x = 40
x + 2

When you execute the code, you get a debugger window that shows you the python code. You can step over or run and the execution will continue and still produce the result.

And a factorial example that relies on an external file:

import gtoolkit_bridge
import gtoolkit_bridge.PythonBridge.tfactorial as tfactorial

The source code of tfactorial can be found at:

GtResourcesUtility default resourceAtPath: Path * 'feenkcom'/ 'PythonBridge' / 'PyPI' / 'src' / 'gtoolkit_bridge' / 'PythonBridge' / ''