from gi.repository import Gdk, Gtk color_str = "#FF0000" color = Gdk.color_parse(color_str) label = Gtk.Label("This label is in red color!") label.modify_fg(Gtk.StateFlags.NORMAL, color)
from gi.repository import Gdk color_str = "rgb(255, 0, 0)" color = Gdk.color_parse(color_str)In this example, we parse a color string "rgb(255, 0, 0)" and create a Gdk.Color object from it. Package Library: This method comes from the Gdk package library.