Interrupting a long-running script - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP) +---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions) +---- Thread: Interrupting a long-running script (/Thread-Interrupting-a-long-running-script) |
Interrupting a long-running script - dfkettle - 01-15-2018 Sorry if this question has already been answered, but I couldn't find anything relevant. How can I interrupt a long-running script if for some reason I don't want to wait for it to complete? The only way I've found is to go into Task Manager (on Windows) and kill it, which isn't very elegant and leaves the do/undo stack in an invalid state, so I have to exit Gimp and restart it. Is there a way to poll the keyboard, say once every 100 ms., and test for a keypress? Or is there another way? Thanks. RE: Interrupting a long-running script - Ofnuts - 01-15-2018 A script (.scm) or a plugin (.py)? Btw when I write my Python scripts/plugin they often crash and yield the "undo stack in an invalid state" message, but this have never been an issue and I don't restart Gimp after that. RE: Interrupting a long-running script - dfkettle - 01-15-2018 (01-15-2018, 08:36 PM)Ofnuts Wrote: A script (.scm) or a plugin (.py)? Btw when I write my Python scripts/plugin they often crash and yield the "undo stack in an invalid state" message, but this have never been an issue and I don't restart Gimp after that. Python. Maybe it isn't necessary to restart Gimp, I was just playing it safe. I'm more concerned about halting a run-away script than having to restart Gimp, anyway. Is there a clean way to do it? Thanks. RE: Interrupting a long-running script - Ofnuts - 01-15-2018 For Python scripts that use an auto-generated parameter dialog, there is a Cancel button, but it is likely that it is only effective if the script uses the progress bar left of the button (but a long-running script ought to do so). RE: Interrupting a long-running script - dfkettle - 01-15-2018 (01-15-2018, 09:17 PM)Ofnuts Wrote: For Python scripts that use an auto-generated parameter dialog, there is a Cancel button, but it is likely that it is only effective if the script uses the progress bar left of the button (but a long-running script ought to do so). That sounds like what I'm looking for, and I do have a progress bar in my scripts if they run for more than a few seconds. But I'm not sure what you mean by "auto-generated parameter dialog". Where could I find an example? RE: Interrupting a long-running script - Ofnuts - 01-15-2018 Most Python scripts just declare parameters and Gimp builds a parameter dialog on the fly when they are called. Those that don't either don't take parameters other than image+layer, or have a whole GUI written in Python. For a standard Python script that uses this autogenerated dialog, see Filters>Render>Cloud>Fog... (in your installation as (lib/gimp/2.0/plug-ins/foggify.py). RE: Interrupting a long-running script - dfkettle - 01-15-2018 (01-15-2018, 10:02 PM)Ofnuts Wrote: Most Python scripts just declare parameters and Gimp builds a parameter dialog on the fly when they are called. Those that don't either don't take parameters other than image+layer, or have a whole GUI written in Python. For a standard Python script that uses this autogenerated dialog, see Filters>Render>Cloud>Fog... (in your installation as (lib/gimp/2.0/plug-ins/foggify.py). That's what I'm doing, I just never heard it described as "auto-generated". Here's my registration function: Code: register( |