GIMP Chat
http://gimpchat.com/

[Solved]python fu runmode detection
http://gimpchat.com/viewtopic.php?f=9&t=12938
Page 1 of 1

Author:  jazzon [ Fri Aug 21, 2015 3:57 am ]
Post subject:  [Solved]python fu runmode detection

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...)

Author:  jontait2 [ Fri Aug 21, 2015 7:00 am ]
Post subject:  Re: python fu runmode detection

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).

Author:  jazzon [ Fri Aug 21, 2015 2:02 pm ]
Post subject:  Re: python fu runmode detection

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.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/