Libove Blog

Personal Blog about anything - mostly programming, cooking and random thoughts

https://programming.dev/post/21199936

I've tried this quickly and you can use pango markup to change the text color in the label.

Here is a snippet with a label and a button that changes the text color from blue to red.

    let label = Label::builder().label("<span foreground=\"blue\">Blue text</span>").build();
    label.set_use_markup(true);
    tool_box.append(&label.clone());
    let button = Button::builder().label("Change").build();
    button.connect_clicked(move |button| {
        println!("Moved");
        label.set_label("<span foreground=\"red\">Red text</span>");
    });
    tool_box.append(&button.clone());

#rust #gtk #gkt-rs