Dear Jehan Pagès, Thanks for reply. Mostly yes. There will probably be some more changes so you will have to > change more from time to time until GIMP 3 release (when it will be > finalized). > Basically, the current scripting style is on a new stage, isn't it? We can learn the basic writing from this. Not really. This is on my TODO list to write proper docs. We have some > starts in the devel-docs/GIMP3-plug-in-porting-guide/ folder in the > repository, but nothing yet which you can really call a proper > "documentation". > Maybe, because of the difference from GIMP 2.10 scripting, many people will need the guide to write/rewrite. I think that the porting will be not so easy... I feel that the hurdle is higher than before when it was possible to replace api name/enumeration name. Even now, there is a lot of talk that old plug-ins don't work, but with GIMP 3, many more/most will be wiped out. > It's never premature to write docs. Sure there will be changes, and sure > it means some of the docs will be wrong and need to be changed before > release. But better start early and fix as we go than write dozens of pages > of documentation at the last minute. > > This is actually a good way to contribute to GIMP with other than code. > The few random files we have in devel-docs/GIMP3-plug-in-porting-guide/ > were written by several people already. If you port your own plug-ins and > want to write documentation, do not hesitate. Right now it's a mess because > everyone wrote a bit of what they wanted, but with time and more people > giving time into it, the documentation will organize itself. 🙂 > Let's port! Thanks. PS; I tried writing template from GIMP 2.99.6 Foggify.py. So, attached. (Maybe, including many wrong points. UTF-8 CrLf) 2021年8月2日(月) 19:08 Jehan Pagès <jehan.marmottard@xxxxxxxxx>: > Hi! > > On Mon, Aug 2, 2021 at 9:38 AM ShiroYuki Mot via gimp-developer-list < > gimp-developer-list@xxxxxxxxx> wrote: > >> It is the Question (same as >> https://gitlab.gnome.org/GNOME/gimp/-/issues/7114) >> Please teach me. >> >> At the next coming 2.99.8, the Python script will avoid the crash. (See >> #7106 (closed)) >> (https://gitlab.gnome.org/GNOME/gimp/-/issues/7106) >> So, One question I have. It is not the issue!. >> >> Can I rewrite my own Python scripts by referring to the foggify.py >> (official one) writing style bundled with GIMP 2.99.8? >> > > Mostly yes. There will probably be some more changes so you will have to > change more from time to time until GIMP 3 release (when it will be > finalized). > > Because of I think that the scripting is so far from GIMP 2.10 era... (Too >> high hardles / So difficult) >> > > It's actually simpler in many ways, but yeah it changed (though bases > concepts still are the same). That's a fact. Also the Python binding used > to have some of the new features already (like dialog generation) which > makes the improvements less visible for people who were already making > Python plug-ins. > > Are there any points to be aware of? >> Or does the documentation exist for GIMP 3 scripting? >> > > Not really. This is on my TODO list to write proper docs. We have some > starts in the devel-docs/GIMP3-plug-in-porting-guide/ folder in the > repository, but nothing yet which you can really call a proper > "documentation". > > Is it premature? (Is it better to wait for a while? Will some change come?) >> > > It's never premature to write docs. Sure there will be changes, and sure > it means some of the docs will be wrong and need to be changed before > release. But better start early and fix as we go than write dozens of pages > of documentation at the last minute. > > This is actually a good way to contribute to GIMP with other than code. > The few random files we have in devel-docs/GIMP3-plug-in-porting-guide/ > were written by several people already. If you port your own plug-ins and > want to write documentation, do not hesitate. Right now it's a mess because > everyone wrote a bit of what they wanted, but with time and more people > giving time into it, the documentation will organize itself. 🙂 > > Jehan > > _______________________________________________ >> gimp-developer-list mailing list >> List address: gimp-developer-list@xxxxxxxxx >> List membership: >> https://mail.gnome.org/mailman/listinfo/gimp-developer-list >> List archives: https://mail.gnome.org/archives/gimp-developer-list >> > > > -- > ZeMarmot open animation film > http://film.zemarmot.net > Liberapay: https://liberapay.com/ZeMarmot/ > Patreon: https://patreon.com/zemarmot > Tipeee: https://www.tipeee.com/zemarmot >
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # shebang & encoding import gi gi.require_version('Gimp', '3.0') from gi.repository import Gimp gi.require_version('GimpUi', '3.0') from gi.repository import GimpUi from gi.repository import GObject from gi.repository import GLib from gi.repository import Gio # Set Libraries # If need more, add import <lib> import gettext _ = gettext.gettext def N_(message): return message # Fixed ? def <func>(procedure, run_mode, image, n_drawables, drawables, args, data): config = procedure.create_config() config.begin_run(image, run_mode, args) if run_mode == Gimp.RunMode.INTERACTIVE: GimpUi.init('python-fu-<func>') dialog = GimpUi.ProcedureDialog.new(procedure, config) dialog.fill(None) if not dialog.run(): dialog.destroy() config.end_run(Gimp.PDBStatusType.CANCEL) return procedure.new_return_values(Gimp.PDBStatusType.CANCEL, GLib.Error()) else: dialog.destroy() <arg1> = config.get_property('<arg1>') <arg2> = config.get_property('<arg2>') # Start Executing Gimp.context_push() image.undo_group_start() # Add Codes # Main Scripting ''' # Call Registed Procedure Sample Gimp.get_pdb().run_procedure('plug-in-plasma', [ GObject.Value(Gimp.RunMode, Gimp.RunMode.NONINTERACTIVE), GObject.Value(Gimp.Image, image), GObject.Value(Gimp.Drawable, mask), GObject.Value(GObject.TYPE_INT, int(time.time())), GObject.Value(GObject.TYPE_DOUBLE, turbulence), ]) ''' # End Executing Gimp.displays_flush() image.undo_group_end() Gimp.context_pop() config.end_run(Gimp.PDBStatusType.SUCCESS) return procedure.new_return_values(Gimp.PDBStatusType.SUCCESS, GLib.Error()) # Registration class <Func> (Gimp.PlugIn): ## Parameters ## __gproperties__ = { "<arg1>": (str, _("<DisplayName>"), _("<Description>"), _("<DefaultValueStr>"), GObject.ParamFlags.READWRITE), "<arg2>": (float, _("<DisplayName>"), _("<Description>"), _("<DefaultValueMin>, <DefaultValueMax>, <DefaultValueStep>"), GObject.ParamFlags.READWRITE), } ## GimpPlugIn virtual methods ## def do_query_procedures(self): self.set_translation_domain("gimp30-python", Gio.file_new_for_path(Gimp.locale_directory())) return [ '<func>' ] def do_create_procedure(self, name): procedure = Gimp.ImageProcedure.new(self, name, Gimp.PDBProcType.PLUGIN, <func>, None) procedure.set_image_types("RGB*, GRAY*"); procedure.set_sensitivity_mask (Gimp.ProcedureSensitivityMask.DRAWABLE | Gimp.ProcedureSensitivityMask.DRAWABLES) procedure.set_documentation (N_("<Description>"), "<Detail.>", name) procedure.set_menu_label(N_("<Func>...")) procedure.set_attribution("<Owner>", "<Owner>", "<Year>") procedure.add_menu_path ("<Image>/Filters/Decor") procedure.add_argument_from_property(self, "<arg1>") procedure.add_argument_from_property(self, "<arg2>") return procedure # Entry Point Gimp.main(<Func>.__gtype__, sys.argv) ## Create from 2.99.6 Foggify.py (Official)
_______________________________________________ gimp-developer-list mailing list List address: gimp-developer-list@xxxxxxxxx List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list List archives: https://mail.gnome.org/archives/gimp-developer-list