Switch to full style
Ask all general Gimp related questions here
Post a reply

How to call a python filter to run interactively

Wed Sep 13, 2023 12:04 am

GIMP Version: 2.10.32
Operating System: Windows
GIMP Experience: Intermediate Level



In one of my exhausted neurons, there is a memory of a test performed -"once upon a time"- in a python filter to call another python filter requesting to run it interactively.
Vaguely I remember that it was not used as the first parameter (it gives error), but likely at the end -or in another way-.
Is my memory totally wrong or is it possible from inside a python filter to call another one asking to get the parameters panel?
I do not find any trace in my repository.
Thanks!

Re: How to call a python filter to run interactively

Wed Sep 13, 2023 2:17 am

Add a keyword "run_mode" argument (this is valid for all filters and scripts that you AFAIK, not just the Python ones):

Code:
pdb.gimp_file_save(image, exportLayer,filename,filename,run_mode=RUN_INTERACTIVE)

Re: How to call a python filter to run interactively

Wed Sep 13, 2023 2:29 am

Thanks Ofnuts.
So my old neuron was not totally wrong.
I'll try it.

Re: How to call a python filter to run interactively

Wed Sep 13, 2023 5:00 am

It seems to work, in the sense that it launches and shows the panel of the called filter.
After pressing Enter it starts doing its steps but it stops half the way without outcome, without errors.
I noticed that when it launches the called filter not all parameters I've prepared are shown, they are limited to 7 (the called filter has more); is there a limit?

Re: How to call a python filter to run interactively

Wed Sep 13, 2023 5:02 am

PS: the launch without the added parm run_mode=RUN_INTERACTIVE works until the appropriate end.

Re: How to call a python filter to run interactively

Wed Sep 13, 2023 9:16 am

There are filters that behave very differently depending on that parameter. So what is the problem filter?

Re: How to call a python filter to run interactively

Wed Sep 13, 2023 9:46 am

This is the called filter.
This filter works standalone as well as called by the optional calling preset filter directly (NON_INTERACTIVE).
DIEGO_MOSAIC_OpusVermiculatumVitreum2023.7z
(9.1 KiB) Downloaded 23 times

It requires chisel.scm
chisel.7z
(2.68 KiB) Downloaded 21 times

These are the statements in the calling filter:
Code:
   if runMode==1: #NON_INTERACTIVE
        Outcome = pdb.python_fu_OpusVermiculatumVitreum2023(inImage, inLayer,
                             widthheight, inColours, stretch_RGB,
                             restore_original, tileSize,
                             lightEffect, glassEffect, textureLook,
                             doShine, doFlatten)
        return
    else: #INTERACTIVE
        Outcome = pdb.python_fu_OpusVermiculatumVitreum2023(inImage, inLayer,
                             widthheight, inColours, stretch_RGB,
                             restore_original, tileSize,
                             lightEffect, glassEffect, textureLook,
                             doShine, doFlatten,
                             run_mode=RUN_INTERACTIVE)
        return

If you need the complete calling filter I'll post it here also

Re: How to call a python filter to run interactively

Wed Sep 13, 2023 9:56 am

Currently in the main program (attached on previous post) there is a trace display image before the statement which causes the stop after the first execution of
Code:
pdb.plug_in_sel2path (img, scratch_layer)
when called INTERACTIVE

Re: How to call a python filter to run interactively

Wed Sep 13, 2023 3:09 pm

First thing first, "run_mode" can be RUN_INTERACTIVE, RUN_NONINTERACTIVE, or RUN_WITH_LAST_VALS, so you don't need two calls, you can use runMode directly

Code:
Outcome = pdb.python_fu_OpusVermiculatumVitreum2023(inImage, inLayer,
                             widthheight, inColours, stretch_RGB,
                             restore_original, tileSize,
                             lightEffect, glassEffect, textureLook,
                             doShine, doFlatten,
                             run_mode=runMode)

Also your comments are wrong, the opposite of RUN_INTERACTIVE is RUN_NONINTERACTIVE, or RUN_WITH_LAST_VALS , so currently you don't really know which one is used.

Re: How to call a python filter to run interactively

Wed Sep 13, 2023 9:02 pm

Appreciate your clarification, ofnuts.
But it is the call without that parameter specified which operates correctly, and not the one with the mode specified.
The "else" in my calling filter is related to my options specified in the caller, which are only two:
Code:
      (PF_OPTION, "runm", "Run mode", 1,
                                        ("INTERACTIVE",
                                         "NON_INTERACTIVE",
                                          )),

Anyhow I will try to run specifying always the mode.

Re: How to call a python filter to run interactively

Wed Sep 13, 2023 9:56 pm

No, with the parameter "run_mode=..." it doesn't work.
I give up and continue calling the execution filter without that parameter (hence default NONINTERACTIVE).
Thanks for your support.

Maybe this was the result also years ago, when I tried it in the past, and therefore I removed also at that time the mode
Post a reply