Gimp-Forum.net

Full Version: User paintbrush input?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi! I'm a beginner to scripting in Gimp (I'm using Python-Fu) and have a quick question to see if what I want to script is even possible. 

I want to be able to create my own selection technique that colors pixels based on a users paintbrush input. (The painted pixels would then be used to draw the segmentation.) I've done some digging in the PDB but have been getting stuck when it comes to obtaining this type of user input (I know you can pass in a paintbrush as a basic parameter but am not sure how you would be able to keep track of where a user has painted on an image). 

Does anyone 1) know if this is possible and 2) would be able to point me in the right direction if it is? Thank you so much. 

(I'm running Gimp 2.10 on Mac Mojave.)
Could you expand on that a bit? What you are talking about looks a lot like the "quickmask"...
I'm basically wondering whether or not it would be possible to script my own custom version of a quickmask.
There is no way for a script (or plug-in) to react to gimp events like painting on the canvas.

You can do a script with 2 input layers, one for the layer to segment and one for regions constraints.
The workflow would be:
1. user draws on the regions constraints layer
2. user calls the script with the 2 layers to obtain the result
3. repeat from 1 if not satisfied

Another approach more user friendly:
1. user calls the script with the 2 layers; the dialog window contains a refresh button
2. user draws on the regions constraints layer
3. user clicks the refresh button to see the result ; the script stays alive (its window is not closed)
4. repeat 2 and 3 if not satisfied
5. close the script dialog

This requires to create a custom script dialog (to add the button) and manage the click > update segementation > refresh gimp selection
(07-02-2019, 08:47 AM)tmanni Wrote: [ -> ]There is no way for a script (or plug-in) to react to gimp events like painting on the canvas.

You can do a script with 2 input layers, one for the layer to segment and one for regions constraints.
The workflow would be:
1. user draws on the regions constraints layer
2. user calls the script with the 2 layers to obtain the result
3. repeat from 1 if not satisfied

Another approach more user friendly:
1. user calls the script with the 2 layers; the dialog window contains a refresh button
2. user draws on the regions constraints layer
3. user clicks the refresh button to see the result ; the script stays alive (its window is not closed)
4. repeat 2 and 3 if not satisfied
5. close the script dialog

This requires to create a custom script dialog (to add the button) and manage the click > update segementation > refresh gimp selection

Great, that answers my question, thank you!