Some more on styling...



Here's the code I'm using (in gtkmm 3. Apparently gtk 4, and hence gtkmm 4, is not available for Raspberry Pi yet)

static const Glib::ustring STYLE_SHEET = "#timer { font: 150pt Arial, sans-serif; background-color: #0000ff; }";
.
.
.

m_css = Gtk::CssProvider::create();
if (! m_css->load_from_data(STYLE_SHEET)) {
std::cerr << "Failed to load CSS" << std::endl;
std::exit(1);
}

m_label_timer.set_name("timer");
auto screen = Gdk::Screen::get_default();
auto context = m_label_timer.get_style_context();
context_add_provider_for_screen(screen, m_css, GTK_STYLE_PRIORITY_APPLICATION);

There are no compiler errors, no messages, and the program does run. It's just that the label's font is not any bigger than without the style sheet stuff and the background is not blue.

Anyone with any ideas?


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