It is currently Thu Jul 04, 2024 4:34 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: [Solved]python fu runmode detection
PostPosted: Fri Aug 21, 2015 3:57 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Aug 13, 2015
Posts: 312
Location: Somewhere between lost and found.
Scripts in Gimp, whether in scheme, or in python, are running in one of three modes:
1 Interactive
2 Non-Interactive
3 Reuse last values.

From a scheme written plugin, determining the mode is easy since it is passed in as a parameter.

How (if it is even possible) is it done in a python-fu plugin?

(I have a plugin which has to return two values visually (via gimp-message) if in interactive mode, or as a tuple (gimp list) if otherwise...)

_________________
The answer was 42. The question is long forgotten. The computer that solved it is now destroyed.
The MK-2 has been built. Should this be the next question?
(Solve if you can ... ;) )
Image


Last edited by jazzon on Fri Aug 21, 2015 2:03 pm, edited 1 time in total.

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: python fu runmode detection
PostPosted: Fri Aug 21, 2015 7:00 am  (#2) 
Offline
Script Coder
User avatar

Joined: Dec 27, 2014
Posts: 508
Short answer: not possible
.. the run_mode parameter is used by the gimpfu module to decide how to run the script but is not passed through to the script itself (see gimpfu.py procedure _run()

Longer answer: you could write your script as a non-Fu Python plugin (ie. one which does not import gimpfu) but that means setting-up the plugin interface and creating/executing the interactive dialog yourself ..which is a right PITA if you've got a lot of input parameters (see eg. high-end-sharpen.py or the Color Grading plugin)

Simplest answer (probably): just make the output-mode itself a parameter (eg. a PF_TOGGLE which defaults to TRUE, meaning output as gimp-message, and set that parameter to FALSE when invoking non-interactively).


Top
 Post subject: Re: python fu runmode detection
PostPosted: Fri Aug 21, 2015 2:02 pm  (#3) 
Offline
GimpChat Member
User avatar

Joined: Aug 13, 2015
Posts: 312
Location: Somewhere between lost and found.
jontait2 Thank you for a simple and concise response. Funnily enough you outlined exactly the steps I had taken (right down to the plugin I used for researching this), and the solution I had adopted. I only posted this here 'cause I was hoping I had misinterpreted something in _run. Oh well.

_________________
The answer was 42. The question is long forgotten. The computer that solved it is now destroyed.
The MK-2 has been built. Should this be the next question?
(Solve if you can ... ;) )
Image


Top
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Line Art Detection

0

No new posts Line art detection bucket fill

0

No new posts Attachment(s) Canny Edge Detection Gimp 2.10 Win10 32/64 bit.

25

No new posts Attachment(s) Canny Edge Detection Gimp 2.10 Linux 64 bit

4

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

4



* Login  



Powered by phpBB3 © phpBB Group