EDITED HEAVILY with some new information (and a bounty)
I am trying to create a plug in in python for gimp. (on windows) this page http://gimpbook.com/scripting/notes.html suggests running it from the shell, or looking at ~/.xsession-errors
neither work. I am able to run it from the cmd shell, as
gimp-2.8.exe -c --verbose ## (as suggested by http://gimpchat.com/viewtopic.php?f=9&t=751 )
this causes the output from "pdb.gimp_message(...)" to go to a terminal.
BUT !!! this only works when everything is running as expected , i get no output on crashes.
i've tried print statements, they go nowhere.
this other guy had a similar problem , but the discussion got sidetracked. Plugins usually don't work, how do I debug?
in some places i saw recommendations to run it from within the python-fu console.
this gets me nowhere. i need to comment out import gimpfu, as it raises errors, and i don't get gtk working.
my current problem is that even if the plugin registers and shows on the menu, when there is some error and it does not behave as expected, i don't know where to start looking for hints . (i've tried clicking in all sorts of contexts, w - w/o selection, with w/o image. )
I was able to copy , and execute example plugins from http://gimpbook.com/scripting/ and i got the, working, but when a change i make breaks something, i know not what, and morphing an existing program line by line is tedious .(gimp has to be shut down and restared each time)
so to sum up -
1- can i refresh a plugin without restarting gimp ? (so at least my slow-morph will be faster )
2- can i run plug-ins from the python-fu shell. (as opposed to just importing them to make sure they parse.)
3- is there an error-log i am missing, or something to that effect?
4- is there a way to run gimp on windows from a shell to see output ? (am i better off under cygwin (or virtualbox.. ))?
5- i haven't yet looked up how to connect winpdb to an existing process. how would i go about connecting it to a python process that runs inside gimp?
thanks
as noted in How do I output info to the console in a Gimp python script?
add
at the beginning of the plug in file.
You must restart GIMP when you add a script or change register(). No need to restart when changing other parts of the script -- it runs as a separate process and will be re-read from disk each time.
helpful source: http://gimpbook.com/scripting/notes.html
Yes, you can access to your registered plug-in in
python-fu
console as:And can call it like:
Also in
python-fu
dialog console, you can click toBrowse ..
option and find your registered plug-in, and then clickApply
, to import it topython-fu
console.helpful source: http://registry.gimp.org/node/28434
To log, you can define a function like this:
And use it in your code, whenever you want.
To see log of that, in
gimp
program, openError Console
fromDockable Dialogs
inWindows
menu, otherwise a message box will be pop up on every time you make a log.Also you can redirect
stdin
andstdout
to a file,:When you do that, all of
exceptions
will go toerr.txt
and all of print out will be go tolog.txt
Note that open file witha
option instead ofw
to keep log file.helpful sources:
How do I output info to the console in a Gimp python script?
http://www.exp-media.com/content/extending-gimp-python-python-fu-plugins-part-2
I got some error for that, but may try again ...
First install winpdb , and also wxPython ( Winpdb GUI depends on wxPython)
Note that
Gimp
has own python interpreter, and may you want to installwinpdb
to your default python interpreter or to gimp python interpreter.If you install
winpdb
to your default python interpreter, then you need to copyrpdb2.py
installed file to..\Lib\site-packages
of gimp python interpreter path.After that you should be able to import
pdb2
module fromPython-Fu
console of gimp:Now in your plug-in code, for example in your main function add following code:
Next, go to gimp and run your python plug-in, when you run your plug-in, it will run and then wait when reach to above code.
Now to open
Winpdb GUI
go to..\PythonXX\Scripts
and runwinpdb_.pyw
.(Note that when using Winpdb for remote debugging make sure any firewall on the way has TCP port 51000 open. Note that if port 51000 is taken Winpdb will search for an alternative port between 51000 and 51023.)
Then in
Winpdb GUI
fromFile
menu selectattach
and givepass
as password to it, and then you can see your plug-in script on that list, select it and start your debug step by step.helpful resource: Installing PyGIMP on Windows
Useful sources:
http://wiki.gimp.org/index.php/Hacking:Plugins
http://www.gimp.org/docs/python/index.html
http://wiki.elvanor.net/index.php/GIMP_Scripting
http://www.exp-media.com/gimp-python-tutorial
http://coderazzi.net/python/gimp/pythonfu.html
http://www.ibm.com/developerworks/opensource/library/os-autogimp/os-autogimp-pdf.pdf
I am a newbie to python, but I would like to give a shout-out, first to winpdb, and then to this comment for integrating winpdb into GIMP. This same procedure works as well for LibreOffice 4.
If I may be allowed to vent a little; I have a moderate amount of experience with Visual Basic, more or less at a hobbiest level, but I decided a few years ago to get into OpenOffice when MicroSoft threatened to abandon VB for the Mac. I don't want to say that VB in OpenOffice was onerous, but the lack of anything resembling an IDE is tedious. Now, with winpdb, I will never be looking back. It's python from here on out, baby.
Steps taken:
-- As suggested by Omid above, I first got winpdb running out of GIMP (relatively painless).
-- I copied the rpdb2.py file to C:\Program Files\LibreOffice 4\program\python-core-3.3.3\lib\site-packages\rpdb2.py. (Win 7, LibreOffice 4.4.03)
-- I edited the HelloWorld.py file in C:\Program Files\LibreOffice 4\share\Scripts\python directory (saved in WinPDb_HelloWorld.py to same directory).
WinPDb_HelloWorld appears under LibreOffice Macros in the Macro Selector (see https://wiki.openoffice.org/wiki/Python_as_a_macro_language for more on that).
(can't show you a picture - posting as a guest)