I ahve found it useful to use the descriptive part of the parameter definition as a reminder of what the numbers that are set actually mean. Example is
“metal”:(int, “_Metal colour”, “0=Aluminium, 1=Brass, 2=Bronze, 3=Copper, 4=Gold, 5=Nickel, 6=Silver, 7=Titanium, 8=Custom”, 0, 8, 4, GObject.ParamFlags.READWRITE),
Really do need a proper op[tion though!
Respectfully, I don’t know if anyone is working on a direct replacement for PF_ENUM.
Also, the chooser for Layer is done in libgimp.
So if you declare an argument of type Layer for a Python plugin,
wouldn’t GimpProcedureDialog already show a widget for that argument?
(There is a test script Sphere v3 that demonstrates all the widgets for plugin arguments. We need one for Python too, demonstrating the replacements or lack thereof for all the PF_ of PyGimp v2. AFAIK there is only “Test dialog” but it is only demonstrating the widgets for GimpResource.)
TLDR: I think you must build custom GUI, at least for an enum.
I am not actively working on the Python side of plugins, only on ScriptFu.
Whatever I say could be wrong.
I don’t think there will be something like PF_OPTION,
where GIMP creates a GUI widget from a declaration.
In GIMP issues, we discussed something like what was mentioned earlier in this post:
encoding the enum declaration in the blurb string of the argument declaration for a plugin argument.
I don’t think it is going to happen, because we don’t like encoding and decoding in strings.
I might be able to find a reference to the discussion.
(There were other proposals, like declaring an enum into the PDB.)
I believe a Python plugin author will need to do something like what is done in C.
An example is plug-ins/common/align-layers.c.
I am not aware of a Python example (although one is needed.)
Briefly, you create a dialog, then call methods to insert custom widgets,
then call the fill method and it fills in the rest of the widgets
for the declared arguments.
There are Python example plugins for that, except for custom enum widgets?
Arguments are one-to-one with properties of the plugin procedure.
I use “custom” to mean one that the plugin author builds,
versus “stock” for one that GimpProcedureDialog will build automatically.
Widgets for enums are much more complicated than the stock widgets for primitive types.
For a custom enum widget:
Declare an enum in Python.
Use it to create a GimpIntStore, which is a model of an enum.
Pass the model to specialize when you create a GtkIntComboBox.
Call a method of GimpProcedureDialog to insert that custom widget.
Then call the fill method.
We could generalize this, a Python procedure that takes a Python enum,
uses its special methods to create a GimpIntStore.
Then we could put that Python procedure in the GIMP repo,
and all Python plugins could use it.
But there is no precedent for Python modules
that are shipped with GIMP 3.
(I suppose PyGimp was in v2.)
In theory, someone could follow your work with SF_OPTION and fix this for Python as well. I’d be interested in learning more about that, but hopefully someone else will come along who can finish it faster.