You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -11,9 +11,11 @@ This repository aims to improve development of Python plug-ins for [GIMP 3](http
11
11
...
12
12
```
13
13
14
-
* A stub file that can be used in integrated development environments (IDEs) to display code completion suggestions for GIMP procedures, plug-ins and layer effects (arguments, return values, documentation) as you type. A pre-generated stub file is provided, but you may generate one yourself if you use custom plug-ins. Stub files are supported by several IDEs such as [PyCharm](https://www.jetbrains.com/help/pycharm/stubs.html), [PyDev](https://www.pydev.org/manual_101_install.html) (an Eclipse plug-in) or [Visual Studio Code via a plug-in](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance).
14
+
* A stub file that can be used in integrated development environments (IDEs), such as [PyCharm](https://www.jetbrains.com/help/pycharm/stubs.html), to display code completion suggestions and documentation for plug-ins and layer effects as you type.
15
15
16
-
* A simplified means to register Python plug-ins. See the bottom of the [`generate-pdb-stubs` module](generate-pdb-stubs/generate-pdb-stubs.py) for an example and the documentation of the `register_procedure()` function in the [`wrappers/procedure.py`](wrappers/procedure.py) file for details.
@@ -22,11 +24,24 @@ This repository aims to improve development of Python plug-ins for [GIMP 3](http
22
24
* Python 3.9 or later
23
25
24
26
25
-
## Usage
27
+
## Usage in Python Plug-ins
26
28
27
-
### Adding the wrappers to your IDE
29
+
There are two main components that you can integrate into your Python plug-in:
30
+
*`pdb` object that allows calling GIMP plug-ins and layer effects (GEGL operations).
31
+
*`procedure` module that allows registering a plug-in procedure with a single function.
28
32
29
-
Place the `pypdb.py` and the `pypdb.pyi` file in the same subdirectory within your Python plug-in.
33
+
These components are independent of each other, i.e. you can use one without the other if you wish.
34
+
35
+
36
+
### Using `pdb` to call plug-ins and layer effects
37
+
38
+
The `pdb` object from the `pypdb` module is used to invoke GIMP plug-ins and layer effects (technically speaking: GEGL operations). `pdb` stands for the GIMP Procedural Database (PDB), which stores all available plug-ins and procedures.
39
+
40
+
You can also use the `pdb` object to call built-in GIMP procedures which are normally accessible via the `Gimp` module.
41
+
42
+
#### Installation
43
+
44
+
Place the `wrappers/pypdb.py` and `wrappers/pypdb.pyi` files in the same subdirectory within your Python plug-in.
30
45
31
46
Example:
32
47
@@ -38,20 +53,16 @@ Example:
38
53
pypdb.pyi
39
54
```
40
55
41
-
IDEs supporting the `.pyi` stub files should now display suggested functions as you type.
42
-
43
-
It is also advised to add `.pyi` files to your `.gitignore` so that git ignores these files:
44
-
45
-
```
46
-
*.pyi
47
-
```
56
+
IDEs supporting the `.pyi` stub files should now display suggested functions as you type. Stub files are supported by several IDEs such as [PyCharm](https://www.jetbrains.com/help/pycharm/stubs.html), [PyDev](https://www.pydev.org/manual_101_install.html) (an Eclipse plug-in) or [Visual Studio Code via a plug-in](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance). Example for PyCharm:
48
57
58
+

59
+

49
60
50
-
### Using the wrappers
61
+
If you use git as your versioning system, add `.pyi` to your `.gitignore` so that git ignores stub files.
51
62
52
-
The `pdb` object from the `pypdb` module is used to invoke GIMP plug-ins, built-in procedures and layer effects (technically speaking: GEGL operations). `pdb` stands for the GIMP Procedural Database (PDB), which stores all available plug-ins and procedures.
63
+
#### Usage
53
64
54
-
Example of importing and using the `pdb` object in a GIMP Python plug-in:
65
+
Example of using the `pdb` object in a GIMP Python plug-in:
55
66
56
67
```
57
68
from pypdb import pdb
@@ -99,16 +110,27 @@ The exit status is available as the `pdb.last_status` property (in the official
99
110
The `pdb.last_error` attribute contains an error message if the last function called via `pdb` failed. Likewise, this does not apply to layer effects.
100
111
101
112
102
-
### Registering your Python plug-in with wrappers
113
+
### Registering your Python plug-in with `procedure`
114
+
115
+
Place the `wrappers/procedure.py` file in the same subdirectory within your Python plug-in.
116
+
117
+
Example:
118
+
119
+
```
120
+
<directory containing GIMP plug-ins>/
121
+
some-plug-in/
122
+
some-plug-in.py
123
+
procedure.py
124
+
```
125
+
126
+
Within the main file of your plug-in (a Python script with same name as its parent directory) import the `procedure` module and call `procedure.register_procedure()` to register a single plug-in procedure. See the bottom of the [`generate-pdb-stubs` module](generate-pdb-stubs/generate-pdb-stubs.py) for an example. The `procedure.register_procedure()` function documentation contains details on the parameters and how they must be formatted.
103
127
104
-
1. Copy the `wrappers/procedure.py` module to your plug-in directory.
105
-
2. Within the main file of your plug-in (a Python script with same name as its parent directory) import the `procedure` module and call `procedure.register_procedure()` to register a single plug-in procedure. See the bottom of the [`generate-pdb-stubs` module](generate-pdb-stubs/generate-pdb-stubs.py) for an example. The `procedure.register_procedure()` function documentation contains details on the parameters and how they must be formatted.
106
-
3. At the end of your main Python module, call `procedure.main()`.
128
+
At the end of your main Python file (`some-plug-in.py` in the example above), call `procedure.main()`.
107
129
108
130
109
-
### Refreshing the stub file by running the stub generator
131
+
##Regenerating the `pypdb.pyi`stub file
110
132
111
-
While this repository provides a pre-generated stub file, it may quickly become obsolete in future GIMP versions and does not display hints for custom plug-ins and scripts you have installed.
133
+
While this repository provides a pre-generated stub file for the `pdb` object, it may quickly become obsolete in future versions of GIMP and does not display hints for custom plug-ins and scripts you have installed.
112
134
In such cases, you may want to generate the stub file yourself as described below.
113
135
114
136
To generate a new stub file, this repository must be installed as a GIMP plug-in.
0 commit comments