Re: Unable to set background color for button

Klaus Rudolph <[email protected]>
Newsgroups gmane.comp.gnome.gtkmm
Message-ID <[email protected]>
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 :-)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.