It is currently Thu Jul 04, 2024 5:22 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: How to develop Python scripts for GIMP?
PostPosted: Thu Jun 25, 2015 2:31 pm  (#1) 
Offline
GimpChat Member

Joined: Jul 06, 2014
Posts: 36
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!

_________________
PixaFlux
Non Destructive Image Editor


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: How to develop Python scripts for GIMP?
PostPosted: Thu Jun 25, 2015 4:11 pm  (#2) 
Offline
New Member

Joined: Jun 25, 2015
Posts: 3
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


Top
 Post subject: Re: How to develop Python scripts for GIMP?
PostPosted: Thu Jun 25, 2015 4:47 pm  (#3) 
Offline
GimpChat Member

Joined: Jul 06, 2014
Posts: 36
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...

_________________
PixaFlux
Non Destructive Image Editor


Top
 Post subject: Re: How to develop Python scripts for GIMP?
PostPosted: Thu Jun 25, 2015 4:56 pm  (#4) 
Offline
New Member

Joined: Jun 25, 2015
Posts: 3
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


Top
 Post subject: Re: How to develop Python scripts for GIMP?
PostPosted: Fri Jun 26, 2015 3:38 am  (#5) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
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 2992 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 2992 times ]

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

Kevin


Top
 Post subject: Re: How to develop Python scripts for GIMP?
PostPosted: Fri Jun 26, 2015 3:53 pm  (#6) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4756
Some tips here

_________________
Image


Top
 Post subject: Re: How to develop Python scripts for GIMP?
PostPosted: Fri Jun 26, 2015 5:07 pm  (#7) 
Offline
GimpChat Member

Joined: Jul 06, 2014
Posts: 36
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...

_________________
PixaFlux
Non Destructive Image Editor


Top
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Can someone please convert these two python scripts for Gimp 2.99.19

10

No new posts Convert GIMP plugin from Python 2 to Python 3

4

No new posts Difference between "Python-Fu" and "Python" plugin

6

No new posts Attachment(s) very old scripts

11

No new posts SCRIPTS CONPATIBLE OR NOT

1



* Login  



Powered by phpBB3 © phpBB Group