[Gimp-user] Help with python-fu
- From: Alussam <forums gimpusers com>
- To: gimp-user-list gnome org
- Subject: [Gimp-user] Help with python-fu
- Date: Tue, 18 Feb 2020 17:40:19 +0100
Your script registers (shows up in menus, listed in pluginrc), so you
have it basically right.
When you run it you get his message (may require to use Gimp-console
if
you are on Windows):
Traceback (most recent call last):
File "/app/lib/gimp/2.0/python/gimpfu.py", line 857, in _run
res = apply(func, params[1:])
TypeError: crop_all_layers() takes exactly 1 argument (2 given)
This is because your function takes one single argument ("image"), and
since your plugin is using old-style registration, an image and a
layer
are always implied as the first two arguments, so you need at least
two
arguments in your function (and you can ignore the second).
A better approach is to use new-style registration. In this
registration
model, the menu entry is split in two: the menu label as before, but
without any path, and a named "menu" argument with the path:
Old style:
register(
"crop-all-layers","","","Alex","Alex","2020",
"<Image>/Filters/Artistic/_croplayers...",
"RGB*, GRAY*",
[],
[],
crop_all_layers,
)
New style:
register(
"crop-all-layers","","","Alex","Alex","2020",
"_croplayers...",
"RGB*, GRAY*",
[],
[],
crop_all_layers,
menu="<Image>/Filters/Artistic/"
)
However with the new style registration, there are no implicit
arguments, so you have to declare your image argument:
register(
"crop-all-layers","","","Alex","Alex","2020",
"_croplayers...",
"RGB*, GRAY*",
[(PF_IMAGE, "image", "Input image", None)],
[],
crop_all_layers,
menu="<Image>/Filters/Artistic/"
)
And then of course use a function that takes a single argument, the
image.
Some hints to debug your scripts, especially if you are on Windows:
https://www.gimp-forum.net/Thread-Debugging-python-fu-scripts-in-Windows
PS: Couldn't see anything useful in your video, it is too fuzzy to see
the labels. Best make static screenshots, and copy/paste any error
messages as text.
Thanks a lot! I will try it now
--
Alussam (via www.gimpusers.com/forums)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]