2 hours ago
(10-05-2025, 01:02 AM)elindarie Wrote:Code:
Gimp.Image.select_rectangle(image, Gimp.ChannelOps.REPLACE, 60.0, 80.0, 100.0, 150.0)
How I got from "gimp_image_select_rectangle" to "Gimp.Image.select_rectangle" wasn't clear, and when I looked up the constants for Gimp.ChannelOps.REPLACE,
at https://developer.gimp.org/api/3.0/libgi...elOps.html
it shows GIMP_CHANNEL_OP_REPLACE
from which it wasn't clear to me that this could be Gimp.ChannelOps.REPLACE.
I would be happy to help improve the documentation, which I found sparse and confusing.
I would be grateful if anyone could tell me how to change the dark blue font in the GIMP python console (without changing the Dark Colors scheme), because I couldn't read it at all unless I highlighted it so it showed as reverse video. I couldn't figure out where, maybe in what css file, this is defined. I'm using gnome and X11.
To do this, it was a lot of hit and miss, and searching for other people's scripts and trying to find similar code in theirs. Also, I don't really understand how to convert from pdb to non-pdb function calls and back.
I guess my next step is to convert this to a plug-in (.py) file.
You're looking at the documentation for C, so it's normal that it's not obvious.
The same doc for Python is here:
https://lazka.github.io/pgi-docs/#Gimp-3..._rectangle
and the detail for the enum is there:
https://lazka.github.io/pgi-docs/Gimp-3....ChannelOps
One has still to figure out that Gimp.ChannelOps(value) can be written Gimp.ChannelOps.REPLACE, which I recognize is not obvious. Took me a few tries.
I guess (didn't try) the short form would be Gimp.ChannelOps(2), but it's less explicit.
If you want to go one step further, I'd suggest you, as an exercise, to try to select the current image instead of creating one. ;-)

