11-04-2024, 08:09 AM
(11-04-2024, 02:48 AM)nchen Wrote:(11-03-2024, 11:58 PM)inkdolls Wrote: Looking at your files, you're using identical functions in many files. I don't know if you're aware that you can declare more than one plugin in one file calling register() repeatedly with different parameters for all the dialogs and a different function each time, so the basic code exists just once, making maintenance easier.
After more than a decade writing plugins, I learned that only quite recently.
Thank you, that is very good to know! So essentially I just create one python file containing all of the plugins in a bundle?
I had tried creating classes for the plugins but it became too convoluted, so I'll definitely have to give this a shot. I just manually copied and pasted all of the functions in alphabetical order, for each plugin...
Hopefully things get a bit easier with GIMP 3 as well.
You can indeed register several plugins in a single Python file, but since 2.10 you can also do something else: put all your "common" code in a separate module
plug-ins
├── bar
│ ├── bar.py
│ └── libmodule.py
├── baz
│ ├── baz.py
│ └── libmodule.py
└── foo
├── foo.py
└── libmodule.py
- Each plugin in its own directory, together with all necessary files
- In such directories, Gimp only tries to register the executable that bears the same name as the directory, the other executables are ignored
- You of course distribute a copy of libmodule.py with each script, but given the size of python files the disk waste is minimal and you gain some upgrade independence