c gtk3 风格 - 按钮的背景没有改变
c gtk3 style - button's background doesn't change
我使用具有 css 样式的 GTK3 编写程序,它在我的 KDE 上运行完美。
但问题是,在 ubuntu 和 windows 10 上,样式仅部分起作用。
我有这样的 css 文件:
window {
background-color: white;
}
button {
border: none;
color: white;
padding: 15px 32px;
text-decoration: none;
font-size: 16px;
background-color: #555555;
}
除了更改按钮的背景外,一切正常。
这就是我加载 css:
的方式
GtkCssProvider *provider = gtk_css_provider_new ();
gtk_css_provider_load_from_path (provider, "styles.css", NULL);
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
GTK_STYLE_PROVIDER(provider),
GTK_STYLE_PROVIDER_PRIORITY_USER);
我怎样才能让它发挥作用?
我找到了解决方案:
window {
background-color: white;
}
button {
border: none;
padding: 0px;
text-decoration: none;
font-size: 16px;
}
button > label{
padding: 15px 32px;
background-color: #555555;
color: white;
}
我使用具有 css 样式的 GTK3 编写程序,它在我的 KDE 上运行完美。 但问题是,在 ubuntu 和 windows 10 上,样式仅部分起作用。 我有这样的 css 文件:
window {
background-color: white;
}
button {
border: none;
color: white;
padding: 15px 32px;
text-decoration: none;
font-size: 16px;
background-color: #555555;
}
除了更改按钮的背景外,一切正常。 这就是我加载 css:
的方式GtkCssProvider *provider = gtk_css_provider_new ();
gtk_css_provider_load_from_path (provider, "styles.css", NULL);
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
GTK_STYLE_PROVIDER(provider),
GTK_STYLE_PROVIDER_PRIORITY_USER);
我怎样才能让它发挥作用?
我找到了解决方案:
window {
background-color: white;
}
button {
border: none;
padding: 0px;
text-decoration: none;
font-size: 16px;
}
button > label{
padding: 15px 32px;
background-color: #555555;
color: white;
}