03-03-2024, 09:04 PM
(03-03-2024, 06:21 PM)gimpygirl Wrote:(03-03-2024, 05:13 PM)Ofnuts Wrote:(03-03-2024, 01:56 AM)gimpygirl Wrote: Hi
Since it's not possible to debug a plugin on windows (maybe it can on linux?) I want to make a way to 'pause' execution of a plugin. Why I want to do that? I want to check in gimp if some code was executed correctly.
For example: I add an alpha channel to a layer in the code, and I then want to 'pause' and check in gimp if it's added by right clicking the layer. And then continue my code.
Is there a way I can pause the code by showing a message box (after the code line I want it to stop) or something that needs to be closed before the code continues? Or another way? Keyboard input is not possible I think?
Please note I'm making a plugin WITHOUT GUI.
Typically I raise an exception where I want the code to stop: raise Exception("Stopping after adding mask"), but my script run inside a try/except block. But this isn't a breakpoint since the code will never restart afterwards. The closest you can be to a break point is to make the code sleep a bit:
Code:
import time
time.sleep(10) # sleep 10 seconds
IS there a true way to debug gimp plugins? Either on windows or linux?
No realistic way to run a debugger in a Gimp plugin. In theory, you could tweak either the Gimp configuration (windows) or the script shebang (Linux/OSX) to have the script be run by a debugger app, but I don't know anyone who tried that.
From Brian Kernighan, the "inventor" of the C language and the guy who wrote a good deal of early Unix;
Quote:The most effective debugging tool is still careful thought, coupled with judiciously placed print statements.
- "Unix for Beginners" (1979)
Personally, as a professional software developer, I rarely use debuggers, and in practice the "careful thought" part of debugging seems to be the most important, people good with debuggers are also good with print statements.