Re: Unable to set background color for button



I tried now the following, but it still doesn't work:


int main(int argc, char *argv[])
{
    auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example");

    Gtk::Window window;

    Gtk::Button button("Some text");
    window.add(button);

    Gdk::RGBA color;
    color.set_rgba(0xff,0x00,0x00,1.0);

    Glib::RefPtr<Gtk::CssProvider> css_provider =
Gtk::CssProvider::create();

    css_provider->load_from_data("button {background-color: #ff0000;}");

    button.get_style_context()->add_provider( css_provider,
GTK_STYLE_PROVIDER_PRIORITY_USER);


    window.show_all_children();

    return app->run(window);
}

Any ideas?

Where can I find the reference which styles from the style sheet each of
the widgets uses? Is there something like a tag/value reference??

I still only want to set the background color of a single button :-)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]