Posts: 74
Threads: 20
Joined: Feb 2024
Reputation:
0
Operating system(s):
- Windows Vista or 7, 8, 10 (64-bit)
Gimp version: 2.10
03-03-2024, 01:56 AM
(This post was last modified: 03-03-2024, 01:57 AM by gimpygirl.)
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.
Posts: 6,216
Threads: 268
Joined: Oct 2016
Reputation:
554
Operating system(s):
Gimp version: 2.10
03-03-2024, 05:13 PM
(This post was last modified: 03-03-2024, 05:15 PM by Ofnuts.)
(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
Posts: 74
Threads: 20
Joined: Feb 2024
Reputation:
0
Operating system(s):
- Windows Vista or 7, 8, 10 (64-bit)
Gimp version: 2.10
(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?
Posts: 6,216
Threads: 268
Joined: Oct 2016
Reputation:
554
Operating system(s):
Gimp version: 2.10
(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.
Posts: 74
Threads: 20
Joined: Feb 2024
Reputation:
0
Operating system(s):
- Windows Vista or 7, 8, 10 (64-bit)
Gimp version: 2.10
(03-03-2024, 09:04 PM)Ofnuts Wrote: (03-03-2024, 06:21 PM)gimpygirl Wrote: (03-03-2024, 05:13 PM)Ofnuts Wrote: 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.
Will GIMP 3 have a debugger? I think it's useful
Why shouldn't python be debugged? You can debug python without gimp
Posts: 6,216
Threads: 268
Joined: Oct 2016
Reputation:
554
Operating system(s):
Gimp version: 2.10
(03-04-2024, 02:40 AM)gimpygirl Wrote: Will GIMP 3 have a debugger? I think it's useful
In Windows? Don't count on it. On Linux, that could possibly be jury-rigged.
(03-04-2024, 02:40 AM)gimpygirl Wrote: Why shouldn't python be debugged? You can debug python without gimp
Because your Python code runs in an environment set up by Gimp, and you would need a combined Gimp+IDE environment.
On the other hand we are talking about scripts, so just Python being the glue around API calls that do the real job and very little logic in Python. You can test these calls in the Python console and when they work move them to your code. And when you have complicated logic, you can factor it in Gimp-independent code, so test/debug it outside of Gimp, and when it works, just copy it to your script.
I use debuggers in C and Java, much less in Python or Bash.
|