several register by python file ? - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP) +---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions) +---- Thread: several register by python file ? (/Thread-several-register-by-python-file) |
several register by python file ? - jacques_duflos - 07-25-2023 I am doing a script that I want to execute very quickly with a shortcut, or more slowly with a option window. Something similar to "save" (quickly executed with ctrl+s) and "save as ..." (with a window to precise options). How should I do ?
The code would look like that : Code: from gimpfu import * RE: several register by python file ? - Ofnuts - 07-25-2023 You can register several plugins in a single python file, just call register() once for each. I have plugins that register twenty of more entries. And remember that there is nothing special to the parameters of register(), they can be variables, so you can define values in a single place (author, copyright, maybe root menu or some plugin parameter definition) and reuse them in each register() call. RE: several register by python file ? - jacques_duflos - 07-30-2023 Ok, great. I have an other question : I would like my quick plug-in to re-use the options last used when calling the slow plug-in. As I noticed that gimp remembers the options of a plug-in when using it several times (instead of falling back to the default values defined in the register), I suppose that they are saved somewhere. I am wandering if I can access those options. If not, what would be the best way of archiving the same result ? Saving the option's values in a file inside the plug-in folder ? In what format ? CSV ? Json ? RE: several register by python file ? - Ofnuts - 07-30-2023 Using the plugin directory itself is dangerous, because the plugin could be installed for the system and so in a directory which is read-only when the plugin is run. using os.path.join(gimp.directory,'plugin-name' seems to be a popular option. For the formatt CSV, is a pain. If you read & write from your code, JSON is somewhat easy. |