This Python script generates predefined completions for PyDev for GIMP 2.8/2.10 and GTK 2 modules to improve development of GIMP plug-ins written in Python.
Development of Python GIMP plug-ins is provided by several Python modules compiled as .pyd
files.
However, PyDev has trouble parsing such files, resulting in missing code completion and Undefined variable from import
error messages.
This script therefore mitigates this problem by generating predefined completions for GIMP modules, GTK modules and GIMP procedures/plug-ins (accessible via gimp.pdb
).
This script is not applicable to GIMP 2.99 or later due to significant changes in the GIMP plug-in API. Some IDEs can already automatically generate predefined completions (stubs) for compiled GIMP 2.99 and GTK 3 modules such as PyCharm. For PyCharm specifically, you may need to add missing stubs. For general development, the Python PDB wrapper can simplify the development of GIMP 2.99 plug-ins.
- GIMP 2.8 or 2.10 (will not work on GIMP 2.99 or later)
- astor library - version 0.6 or later
- Locate the directory for plug-ins in your GIMP installation by going to
Edit → Preferences → Folders → Plug-Ins
. - Choose one of the listed directories there and copy
pypredefgen_gimp.py
andpypredefgen_gimp
to that directory. - Download the astor library and place it in the directory for plug-ins.
- If not available in your Python distribution, install importlib and place it in the directory for plug-ins.
On Linux and possibly macOS, you may install the required libraries via pip
instead:
pip install astor importlib
To run the generator, open GIMP and choose Filters → Python-Fu → Generate Predefined Completions for PyDev
.
You may adjust the output directory.
By default, the predefined completions are located in the [path to GIMP user config]/pypredefs
directory.
Alternatively, you may run the generator from the Python-Fu console - open GIMP, choose Filters -> Python-Fu -> Console
and enter
pdb.python_fu_generate_predefined_completions_for_pydev(None)
To add the predefined completions to PyDev, go to Window → Preferences → PyDev → Interpreters → Python Interpreter
, choose the GIMP Python interpreter and add the directory containing the generated completions as per the instructions.
For GIMP 2.10 on Windows up to 2.10.8, predefined completions for the gimpui
module are not generated due to crashes when accessing certain members of that module.
This issue does not occur from GIMP 2.10.10 onwards.