GIMP Chat
http://gimpchat.com/

How to develop Python scripts for GIMP?
http://gimpchat.com/viewtopic.php?f=9&t=12723
Page 1 of 1

Author:  pixaeiro [ Thu Jun 25, 2015 2:31 pm ]
Post subject:  How to develop Python scripts for GIMP?

Hello,

I have been studying the Python scripting library, and it seems to be very advanced and powerful, but unfortunately I haven't found good documentation for it, and I am pretty much flying blind with it.

I have GIMP 2.8.14 on a Win7 pc.

Does anybody has a link for the API or SDK? I have found this page (http://www.gimp.org/docs/python/) but it seems to be a short introduction to GIMP+Python.

What is the best way to develop scripts for GIMP? Right now I have to edit the script, save, open GIMP, test script, close, repeat... every time... Is there a way to unload a script?

How can I see Python error messages? If something fails, GIMP just shows a 'invalid state' message, but I don't get the Python error message.

Any help on this topic will be greatly appreciated!

Thank you!

Author:  davethecrane [ Thu Jun 25, 2015 4:11 pm ]
Post subject:  Re: How to develop Python scripts for GIMP?

Hi Pixaeiro,

There isn't much good documentation around - I find the best source is the procedure browser and plugin browser (both off the help menu) which give reasonable docs and basic search functionality. But it's a far cry from a proper IDE :)

Two other useful tips:
1. You only need to reload Gimp if you change the signature of the method call or the plugin registration. Once you've set these up, edit the body of the function (and any supporting functions or classes), and the latest version of the script runs every time.

2. If you run Gimp inside a command-line terminal, you can see the python error messages when your script throws errors.

Disclaimer: I run Gimp on Linux, not windows, but I imagine both points are true across platforms.

Hope that helps!

Dave

Author:  pixaeiro [ Thu Jun 25, 2015 4:47 pm ]
Post subject:  Re: How to develop Python scripts for GIMP?

Awesome, not having to close and open GIMP every time will be a great time saver!

I tried running GIMP from a command line, but as soon as I press the Enter key, GIMP is launched and the command returns immediately... but now that you say that is possible I'll try to find a command line argument to keep the command line active.

Thank you Dave...

Author:  davethecrane [ Thu Jun 25, 2015 4:56 pm ]
Post subject:  Re: How to develop Python scripts for GIMP?

Yeah, it was a great day for me when I realised that the scripts would reload if the header/registration hadn't changed!

Regardig cmd line, how are you launching it? I don't have a windows VM to hand, so these instructions may be a bit wobbly, but i would do this, roughly:

1. Open a cmd window from start menu/charms bar by typing "cmd"
2. cd to Gimp installation folder (c:/Program Files/gimp-2.8 ??)
3. type "gimp" or "gimp-2.8"

This ought to launch gimp w/out closing the cmd prompt window. And if the program returns one the Gimp gui launches, it may still be able to spew output into that window. (Try registering a simple python script that divides b zero, say, just to see if you can generate an error?)

cheers, Dave

Author:  paynekj [ Fri Jun 26, 2015 3:38 am ]
Post subject:  Re: How to develop Python scripts for GIMP?

Just to slightly amend Dave's instructions, you need the --verbose option to get the terminal window to show. So it becomes:

1. Open a cmd window from start menu/charms bar by typing "cmd"
2. cd to Gimp binary installation folder (c:/Program Files/gimp-2.8/bin)
3. type "gimp-2.8.exe --verbose"


However, that probably won't get you much as verbose mode on Windows is anything but verbose.

If you have a Python error, you should get an error message:
Attachment:
Untitled2.png
Untitled2.png [ 22.02 KiB | Viewed 2996 times ]


However if you do something that creates a syntax error for example an indentation error, then you'll get an unhelpful message in the GIMP error console:
Attachment:
Untitled3.png
Untitled3.png [ 54.12 KiB | Viewed 2996 times ]

But if you've not got GIMP running and create that error, then your script won't register in the menu.

Kevin

Author:  ofnuts [ Fri Jun 26, 2015 3:53 pm ]
Post subject:  Re: How to develop Python scripts for GIMP?

Some tips here

Author:  pixaeiro [ Fri Jun 26, 2015 5:07 pm ]
Post subject:  Re: How to develop Python scripts for GIMP?

I tried running GIMP with the --verbose flag, but I don't see the window with the Python errors... I get a window telling me the plug-in crashed.
Also, I do see the GIMP error console when the image is left in a bad state, but again, no Python errors.

In any case, just the fact that I don't need to restart GIMP every time I change my script is a huge time saver!

Thank you guys... if I find a way to see the Python errors, I'll post it here!

ps... Thanks ofnuts... I just saw your tips...

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/