It is currently Sat Jun 29, 2024 10:45 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: How to call a python filter to run interactively
PostPosted: Wed Sep 13, 2023 12:04 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
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!

_________________
"Where am I ?"


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: How to call a python filter to run interactively
PostPosted: Wed Sep 13, 2023 2:17 am  (#2) 
Offline
Script Coder
User avatar

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

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

_________________
Image


Top
 Post subject: Re: How to call a python filter to run interactively
PostPosted: Wed Sep 13, 2023 2:29 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Thanks Ofnuts.
So my old neuron was not totally wrong.
I'll try it.

_________________
"Where am I ?"


Top
 Post subject: Re: How to call a python filter to run interactively
PostPosted: Wed Sep 13, 2023 5:00 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
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?

_________________
"Where am I ?"


Top
 Post subject: Re: How to call a python filter to run interactively
PostPosted: Wed Sep 13, 2023 5:02 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
PS: the launch without the added parm run_mode=RUN_INTERACTIVE works until the appropriate end.

_________________
"Where am I ?"


Top
 Post subject: Re: How to call a python filter to run interactively
PostPosted: Wed Sep 13, 2023 9:16 am  (#6) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4752
There are filters that behave very differently depending on that parameter. So what is the problem filter?

_________________
Image


Top
 Post subject: Re: How to call a python filter to run interactively
PostPosted: Wed Sep 13, 2023 9:46 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
This is the called filter.
This filter works standalone as well as called by the optional calling preset filter directly (NON_INTERACTIVE).
Attachment:
DIEGO_MOSAIC_OpusVermiculatumVitreum2023.7z [9.1 KiB]
Downloaded 22 times

It requires chisel.scm
Attachment:
chisel.7z [2.68 KiB]
Downloaded 21 times

These are the statements in the calling filter:
   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

_________________
"Where am I ?"


Top
 Post subject: Re: How to call a python filter to run interactively
PostPosted: Wed Sep 13, 2023 9:56 am  (#8) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
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
pdb.plug_in_sel2path (img, scratch_layer)
when called INTERACTIVE

_________________
"Where am I ?"


Top
 Post subject: Re: How to call a python filter to run interactively
PostPosted: Wed Sep 13, 2023 3:09 pm  (#9) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4752
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

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.

_________________
Image


Top
 Post subject: Re: How to call a python filter to run interactively
PostPosted: Wed Sep 13, 2023 9:02 pm  (#10) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
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:
      (PF_OPTION, "runm", "Run mode", 1,
                                        ("INTERACTIVE",
                                         "NON_INTERACTIVE",
                                          )),

Anyhow I will try to run specifying always the mode.

_________________
"Where am I ?"


Top
 Post subject: Re: How to call a python filter to run interactively
PostPosted: Wed Sep 13, 2023 9:56 pm  (#11) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
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

_________________
"Where am I ?"


Top
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Python calling G'MIC filter? (Solved)

4

No new posts Attachment(s) use of a color curves preset in a python filter

42

No new posts Convert GIMP plugin from Python 2 to Python 3

4

No new posts Attachment(s) cli345's cartoon filter as a native GEGL Filter.

10

No new posts Difference between "Python-Fu" and "Python" plugin

6



* Login  



Powered by phpBB3 © phpBB Group