Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[RFC] Summer of code project to re-think plug-in/filter development resources
#11
MrsP-from-C: Hi! This should be fixed, so can you point to a function you tested that gave the wrong code output? For instance, gimp-edit-named-copy outputs "config.set_core_object_array('drawables', [drawable])" in the Python console.
Reply
#12
That was
script-fu-selection-rounded-rectangle

just yesterday. Thanks for looking into it.

As you are there: could you also look into that output and make it use lines instead of chaining it all in one line?
That would be much easier to handle.
Reply
#13
(06-06-2025, 01:27 PM)MrsP-from-C Wrote: That was
script-fu-selection-rounded-rectangle

just yesterday. Thanks for looking into it.

As you are there: could you also look into that output and make it use lines instead of chaining it all in one line?
That would be much easier to handle.

I just tried with version 3.0.4 and script-fu-selection-rounded-rectangle gives me the right way to set the drawable.

That said, could we, please, stay on topic? For reporting bugs, please, use the bug tracker. And I already opened a ticket regarding both the long lines and that the provided code uses exclusively PDB procedures instead of libgimp wrappers for them. See https://gitlab.gnome.org/GNOME/gimp/-/issues/14266.
Reply
#14
This is what I get using the official 3.0.4 appimage:


   
Reply
#15
(06-19-2025, 02:34 PM)MrsP-from-C Wrote: This is what I get using the official 3.0.4 appimage:

I confirm, had the same problem recently. when I used that to create a call in the Python console.

Otherwise, I'm using this in my code:

Code:
def callProcedure(procId: str, run_mode=Gimp.RunMode.NONINTERACTIVE, **kwargs):
    procedure=Gimp.get_pdb().lookup_procedure(procId)
    if procedure is None:
        raise Exception(f'Procedure "{procId}" no found')
    config: Gimp.ProcedureConfig = procedure.create_config()
    #configuration.set_property('run-mode',run_mode)
    for name,value in kwargs.items():
        if isinstance(value,list):
            config.set_core_object_array(name.replace('_','-'),value)
        else:
            config.set_property(name.replace('_','-'),value)
    result=procedure.run(config)
    results = [result.index(i) for i in range(result.length())]
    if results[0] is not Gimp.PDBStatusType.SUCCESS:
        raise Exception(f'Error returned from procedure "{procId}": {results[0].value_name}')
    return results[1:]

This infers the config data from keyword arguments (python_style_names being replaced by equivalent config-element-names), and handles the set_property/set_core_object_array automatically.

Used like this:

Code:
# Other args of sel2path are default values
    res = callProcedure('plug-in-sel2path', image=scaledImage, drawables=[layer])
Reply
#16
Thank you, Ofnuts.
I'll give that a try.

But honestly: this could be done right in GIMP from the start.
Reply
#17
(06-20-2025, 06:28 AM)MrsP-from-C Wrote: Thank you, Ofnuts.
I'll give that a try.

But honestly: this could be done right in GIMP from the start.

This would be heavily language dependent, and the idea here is that Gimp provides language agnostic interface.

As need arises and because I'm a lazy programmer, I've written a gimphelpers module that makes things a lot simpler (at least for me) by cutting off the boilerplate. This includes the function above but many other things, with the idea to help your IDE tell you in advance that you are talking nonsense.

You can have a peek and are welcome to use it (or even contribute...), see here.
Reply


Forum Jump: