Skip to content

Commit 71b93b7

Browse files
committed
Clarify readme
1 parent c820905 commit 71b93b7

File tree

3 files changed

+45
-23
lines changed

3 files changed

+45
-23
lines changed

README.md

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Wrappers for GIMP Python Plug-ins
22

3-
This repository aims to improve development of Python plug-ins for [GIMP 3](https://www.gimp.org/) by providing the following:
3+
This project aims to improve development of Python plug-ins for [GIMP 3](https://www.gimp.org/) by providing the following:
44

5-
* A simplified means to call GIMP plug-ins, built-in procedures, and apply layer effects (GEGL operations):
5+
* A simplified means to call GIMP plug-ins and apply layer effects (GEGL operations):
66
```
77
...
88
pdb.plug_in_jigsaw(image=image, drawables=[layer])
@@ -11,9 +11,11 @@ This repository aims to improve development of Python plug-ins for [GIMP 3](http
1111
...
1212
```
1313

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.
1515

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.
16+
* A simplified means to register Python plug-ins.
17+
* [Example](https://github.com/kamilburda/gimp-python-wrappers/blob/5.2/generate-pdb-stubs/generate-pdb-stubs.py#L52)
18+
* [Documentation](https://github.com/kamilburda/gimp-python-wrappers/blob/5.2/wrappers/procedure.py#L26)
1719

1820

1921
## Requirements
@@ -22,11 +24,24 @@ This repository aims to improve development of Python plug-ins for [GIMP 3](http
2224
* Python 3.9 or later
2325

2426

25-
## Usage
27+
## Usage in Python Plug-ins
2628

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.
2832

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.
3045

3146
Example:
3247

@@ -38,20 +53,16 @@ Example:
3853
pypdb.pyi
3954
```
4055

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:
4857

58+
![](docs/code_completion_suggestions.png)
59+
![](docs/function_signature_and_description.png)
4960

50-
### Using the wrappers
61+
If you use git as your versioning system, add `.pyi` to your `.gitignore` so that git ignores stub files.
5162

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
5364

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:
5566

5667
```
5768
from pypdb import pdb
@@ -99,16 +110,27 @@ The exit status is available as the `pdb.last_status` property (in the official
99110
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.
100111

101112

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.
103127

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()`.
107129

108130

109-
### Refreshing the stub file by running the stub generator
131+
## Regenerating the `pypdb.pyi` stub file
110132

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.
112134
In such cases, you may want to generate the stub file yourself as described below.
113135

114136
To generate a new stub file, this repository must be installed as a GIMP plug-in.

docs/code_completion_suggestions.png

25.7 KB
Loading
50 KB
Loading

0 commit comments

Comments
 (0)