Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Load multiple plugins from a parent plugin folder
#1
Let say I want to have a folder containing my plugin. As I understand, GIMP only looks for plugins file named as the folder. For example, this works ok:

Code:
my-plugin-folder-name
    my-plugin-folder-name.py

If I change the plugin file name, the plugin will not be loaded. For example:

Code:
my-plugin-folder-name
    something-different.py

In this case the file something-different.py will not be loaded by GIMP, even if it's set to be executable.

Is it possible to force GIMP (from settings) to also look for other file names into plugin subfolders? Ideally, I would like to have multiple files for slightly different plugins into the folder my-plugin-folder-name. Right now with only one file to be loaded, as my plugin get bigger and bigger, it's becoming also messier to keep it "organized"...
Reply
#2
IMHO your best course of action is to have one file containing the registration of all the plugins. The plugin code then mostly imports your other files as python modules. To do so you have to extend the Pyhon path to add the directory where the modules are, which is the directory where your "main"/registration file is. This one can retrieve its location as os.path.abspath(sys.argv[0]). You can also have your functions in the main with one or more python modules for the "ancillaries", or even have one module per function, and all the modules sharing a common "library" module.

Edit: attached ZIP with proof-of-concept code.

Edit2: For completeness, proof-of-concept is now a main that calls modules that call a common library


Attached Files
.zip   Modules.zip (Size: 2.03 KB / Downloads: 201)
Reply
#3
It worked!!! Thank you! Smile
Reply


Forum Jump: