It is currently Sat Jun 06, 2026 6:08 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: register function menu=
PostPosted: Tue Dec 06, 2016 10:52 am  (#1) 
Offline
GimpChat Member

Joined: Nov 08, 2016
Posts: 45
Regarding the menu path in the register function. I've seen it with 1 line (Method 2: lines 7) and 2 lines (Method 1: lines 7 & 12), is there any difference and is one preferred over the other?

Is the only difference between the paths "<Image>" and "<Toolbox>", that "<Image>" provides 2 parameters (image and drawable) to the main function?

I thought I was writing a gimp script in python, but I read they should be installed in the plugin directory. :-) What's the difference between a gimp script and a plug-in?

I don't go to the gimp registry much (because of the warning), but I searched for info on PF_RADIO and a helpful python demo came up in the search:
Demonstrate built-in GUI widgets for Gimp plugins written in Python

# Method 1
register(
1  "function name",
2  "short description",
3  " long description",
4  "author",
5  "copyright",
6  "date",
7  "Ex01: Test Input Parameters...",
8  "image type supported",
9  [input parms],
10 [ results],
11 main function,
12 menu = "<Image>/MyScripts/Examples"
)

# Method 2
register(
1  "function name",
2  "short description",
3  " long description",
4  "author",
5  "copyright",
6  "date",
7  "<Image>/MyScripts/Examples/Ex01: Test Input Parameters...",
8  "image type supported",
9  [input parms],
10 [ results],
11 main function
)


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: register function menu=
PostPosted: Tue Dec 06, 2016 1:35 pm  (#2) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
A Gimp script is run by one single instance of the Scheme interpreter ("lighter", but you can have conflicts betwen functions names across the scripts).

Plugins (and this includes the Python scripts) run in their own process instance, so they are much less likely to conflict with each other.

For registration, I tend to use Method 1 because it makes things easier when you register several function that should end up together in the menus.

_________________
Image


Top
 Post subject: Re: register function menu=
PostPosted: Thu Dec 08, 2016 7:30 pm  (#3) 
Offline
GimpChat Member

Joined: Nov 08, 2016
Posts: 45
Apparently Method 2 is obsolete. So script/plugin writers should be using: "menu=". See Source below. I was trying to find when that changed so I can have a better understanding and catch future changes. I've been looking through the source, change log, and searching the developers list archive, but haven't found any reference yet.

Source:
Beginning GIMP: From Novice to Professional ... by Akkana Peck
The slides were very helpful.

Obsolete menu registration
http://gimpbook.com/scripting/slides30/ ... menu2.html

Where in the menus?
http://gimpbook.com/scripting/slides30/ ... -menu.html

Update:
When I split the menu path from the menu item by using "menu=", the first two parameters (image and drawable) were not passed to the main function and I got the error "takes exactly 4 arguments (2 given)". Everything else in the register function stayed the same.

line 7: "<Image>/MyDemos/Examples/Ex01: Test Input Parameters...",

line 7: "Ex01: Test Input Parameters...",
line 12: menu="<Image>/MyDemos/Examples"

It seems if you use "menu=", then you must explicitly define image and drawable --- if needed. It isn't automatic.

(PF_IMAGE, "image", "Input image", None),
(PF_DRAWABLE, "drawable", "Input drawable", None),


Top
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group