Gimp-Forum.net
Gimp 3.0.6 Python plug-in bug with text layer.set_color(color)? - 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: Gimp 3.0.6 Python plug-in bug with text layer.set_color(color)? (/Thread-Gimp-3-0-6-Python-plug-in-bug-with-text-layer-set-color-color)



Gimp 3.0.6 Python plug-in bug with text layer.set_color(color)? - Volker - 11-18-2025

My environment: Apple Mac mini M2, macOS Tahoe 26.1.

I want to set the color of a text layer from a Python plug-in. In Gimp 2 I used the plug-in "gimp-text-layer-set-color".

In Gimp 3 I find the layer method "set_color(color)", but the color remains to be the foreground color. The same with the PDB plug-in.
First try with layer method:
Code:
textColor = Gegl.Color.new("red") # e.g.
textLayer = Gimp.TextLayer.new(image, "Text", someFont, sometextSize, Gimp.Unit.pixel())
textLayer.set_name("Text")
textLayer.set_color(textColor)
image.insert_layer(textLayer, parent, position)
The text is black.
Next try with pdb proc:
Code:
textColor = Gegl.Color.new("red") # e.g.
textLayer = Gimp.TextLayer.new(image, "Text", someFont, sometextSize, Gimp.Unit.pixel())
textLayer.set_name("Text")
pdb = Gimp.get_pdb()
textLayerSetColor = pdb.lookup_procedure("gimp-text-layer-set-color")
pdbConfig = textLayerSetColor.create_config()
pdbConfig.set_property("layer", textLayer)
pdbConfig.set_property("color", textColor)
textLayerSetColor.run(pdbConfig)
image.insert_layer(textLayer, parent, position)
The text is black.
Next try with foreground:
Code:
textColor = Gegl.Color.new("red") # e.g.
foreground = Gimp.context_get_foreground()
Gimp.context_set_foreground(textColor)
textLayer = Gimp.TextLayer.new(image, "Text", someFont, sometextSize, Gimp.Unit.pixel())
textLayer.set_name("Text")
image.insert_layer(textLayer, parent, position)
Gimp.context_set_foreground(foreground)
Success! The text is red.

Where is the error? With my code or with Gimp?