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
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