RSS/Atom feed Twitter
Site is read-only, email is disabled

Help with python-fu

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

6 of 6 messages available
Toggle history

Please log in to manage your subscriptions.

Help with python-fu Alussam 17 Feb 20:41
  Help with python-fu Ofnuts 17 Feb 23:30
   Help with python-fu Alussam 18 Feb 16:40
  Help with python-fu ReginaLeo 29 Apr 16:18
   Help with python-fu ReginaLeo 29 Apr 16:19
    Help with python-fu ReginaLeo 29 Apr 16:19
2020-02-17 20:41:12 UTC (about 4 years ago)
postings
2

Help with python-fu

Hello! I need some help with writing simple plugin. I tryed to use ready to use plugin code from https://www.gimp.org/docs/python/index.html. But when I used it, seems nothing happens. So I made a simple script, which prints message. But nothing works seems. Please,whatch video for details: https://youtu.be/0vpPaIEUGGE

Thanks for help.

Attachments: * https://www.gimpusers.com/system/attachments/1371/original/script

Alussam (via www.gimpusers.com/forums)
Ofnuts
2020-02-17 23:30:28 UTC (about 4 years ago)

Help with python-fu

On 2/17/20 9:41 PM, Alussam wrote:

Hello! I need some help with writing simple plugin. I tryed to use ready to use plugin code from https://www.gimp.org/docs/python/index.html. But when I used it, seems nothing happens. So I made a simple script, which prints message. But nothing works seems. Please,whatch video for details: https://youtu.be/0vpPaIEUGGE

Thanks for help.

Attachments: * https://www.gimpusers.com/system/attachments/1371/original/script

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", "/Filters/Artistic/_croplayers...", "RGB*, GRAY*",
[],
[],
crop_all_layers,
)

New style:

register(
"crop-all-layers","","","Alex","Alex","2020", "_croplayers...",
"RGB*, GRAY*",
[],
[],
crop_all_layers,
menu="/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="/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.

2020-02-18 16:40:19 UTC (about 4 years ago)
postings
2

Help with python-fu

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", "/Filters/Artistic/_croplayers...", "RGB*, GRAY*",
[],
[],
crop_all_layers,
)

New style:

register(
"crop-all-layers","","","Alex","Alex","2020", "_croplayers...",
"RGB*, GRAY*",
[],
[],
crop_all_layers,
menu="/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="/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)
2021-04-29 16:18:16 UTC (almost 3 years ago)
postings
6

Help with python-fu

Hello! I need some help with writing simple plugin. I tryed to use ready to use
plugin code from https://www.gimp.org/docs/python/index.html. But when I used
it, seems nothing happens. So I made a simple script, which prints message. But
nothing works seems. Please,whatch video for details: https://youtu.be/0vpPaIEUGGE

Thanks for help.

Attachments: * https://www.gimpusers.com/system/attachments/1371/original/script

Python is hard

2021-04-29 16:19:15 UTC (almost 3 years ago)
postings
6

Help with python-fu

Python is hard

I would like to help you, but I am not good at writing. I can recommend a cheap assignment writing service for you that will solve your problem. I have been cooperating with this service for over a year, and I am very pleased with their services. I think you will also appreciate this service.

2021-04-29 16:19:47 UTC (almost 3 years ago)
postings
6

Help with python-fu

I would like to help you, but I am not good at writing. I can recommend a cheap assignment writing service for you that will solve your problem. I have been cooperating with this service for over a year, and I am very pleased with their services. I think you will also appreciate this service.

I would like to help you, but I am not good at writing. I can recommend a cheap assignment writing service for you that will solve your problem. I have been cooperating with this service - https://www.essaygeeks.co.uk/cheap-assignment-writing-service/ for over a year, and I am very pleased with their services. I think you will also appreciate this service.