You are here

python plug-in function gets two parameters more than as indicated in register() and in the definition

Dear Friends,
I am still struggling with the conversion from gimp 2.4 to gimp 2.6 of a modified version of the python plug_in

I succedded in making it appear in the menu but when I run it an error occurs.

In the register() function four arguments are passed to the function process_addresses()
and the same function process_addresses() is defined as accepting four arguments.

However when the plug-in is run an error is displayed saying that 6 parameters were passed and not just four.

I assume that two extra arguments passed are the image and drawable image passed automatically by gimpfu.

Any suggestions ?

Thank you and best regards


It would be easier to track and comment on this specific issue if we kept the issue on the former forum post? Rather than starting a new thread about the same problem?

Dear mahvin,
thank you for your comments.
I thought that while dealing with the same plug-in the issues were different, but maybe you are right. Next time I shall do as you suggest.
Thank you again and best regards.

I substituted the line
elif menu[:7] == '(Image)' or menu[:6] == '(Save):
elif menu[:6] == '(Save):

and in this way I avoided the insertion of the two parameters image and drawable.
Note that in the two lines above I have substituted corner brackets with round brackets to avoid forum software filtering corner brackets.

In the 2.4 version the menu was Toolkit and therefore the two parameters were not
inserted. In the 2.4 version Toolkit menu has ben eliminated and replaced by Image
but in this way the parameters image and drawable are automatically inserted.

The solution that I found is an ad hoc hacking away at code.
What is the proper way of resolving the problem ?
Thank you

Yes, better way. Hacking only works for you, not for the public. Yes, the extra parameters are probably the image and drawable.

In register() function, add the optional keyword parameter:


(substitute less-than and greater-than characters for () characters. Again, this website is mangling less than characters.)

And only put the last word of the menu path in the "label" parameter, e.g. "Golden Labels."

See for an example of a plugin that takes no image or drawable, and installs in the Filter menu.

If you read, you will see that if the optional keyword parameter "menu" is present, it doesn't automatically insert the image and drawable parameters. Something about compatibility which I don't fully understand.

In my limited understanding, at some release of GIMP, it became a convention or standard or preferred way to separate the label from the menu path, by using the additional parameter. IE the full menu path was divided into the prefix (the menu parameter) and the final word, that is the menu item (the label parameter.)

There is probably more to understand: the different cases when the image type parameter is empty, the various plugin types (e.g. extensions, plugins, etc.), the different menu paths (e.g. Image/Filters/Languages) that get mangled to a different path (by GIMP or by gimpfu?). I wish I could point you to one place where it was all explained.

Subscribe to Comments for "python plug-in  function gets two parameters more than as indicated in register() and in the definition"