dinasset wrote:
Hi everybody,
I have some (hopefully not insane...) curiosity on the subject.
1 - why are scripts in python handled as plug-ins? they are interpreted as scripts in scheme are, they are not compiled-executable (IMHO it would have been clearer to have three categories : .scm scripts, .py scripts and .exe plug-ins; -or not to proliferate interpreted and executables-)
2 - why there is no "refresh" function for the python scripts as for the scheme scripts? when there is some error in one script it's a very useful function
3 - when launching gimp in -verbose mode, if in a python scripts there is a formal error it simply does not appear instead of reporting the error found in it; so it is very difficult to find out the error, I know there is the console but it seems to be available only for the operations not for the parameters of the definition (yesterday I was trying to find out what was wrong with a PF_OPTION parameter and spent a lot of time, finally finding the solution in a French chat...)
I hope among those of you who like programming for gimp there is somebody who likes to give some answer to a novice...
Thanks
1) Because they are really executing as independent processes, like other plugins. A python plugin can do a lot more things than a Scheme script (previews in its own windows, direct pixel access, etc...)
2) Possible explanation: The scripts are self-contained, you can't change the script function without changing the script file, so refreshing the scripts only deals with the changed .scm files. On the other hand a plugin may be spread over several files, but Gimp only knows about the "main" executable, to it would have to unconditionally re-run all plugins to make sure. In practice, the refresh is only useful if you change the registration code... if you fix the code elsewhere, you can run the script again and it will use the new code.
3) If there is a registration error you are told (not even in verbose mode):
Traceback (most recent call last):
File "/home/me/.gimp-2.6/plug-ins/bad-path-dump.py", line 115, in <module>
domain=("gimp20-python", gimp.locale_directory)
File "/usr/lib/gimp/2.0/python/gimpfu.py", line 228, in register
"elements (%s given: %s)" % (len(ent), ent))
gimpfu.error: parameter definition must contain at least 4 elements (3 given: (1001, 12, (0, 3, 1)))
But it's not a problem of Gimp being verbose or terse, since the errors are printed by the failing plugin. Its a problem of displaying output. On Linux, if you start Gimp from a terminal, all errors are printed to the terminal. In Windows, programs with windows have nowhere to send their output. AFAIK, the gimp-console executable is meant to give them somewhere to display things. You can also use a try/except around the registration code and write the error message to some file.
You can weed out your major syntax blunders by running the script outside of Gimp:
When it complains about gimpfu missing, then there are no more syntax errors.