【问题标题】:How to add css style to GtkBox in Gtk+ 3如何在 Gtk+ 3 中为 GtkBox 添加 CSS 样式
【发布时间】:2013-07-14 14:01:13
【问题描述】:

我想用 GTK+ 3 和 Python 创建一个 Ubuntu 应用程序,但我是 GTK 新手。

我在下图中有一个 gtkbox 的 css 样式,但我怎样才能将此样式添加到我的 GtkBox/GtkVBox 对象中,使其与图像中的一样。
image of my concept

注意:此图片由 Photoshop 创建。

【问题讨论】:

  • 到目前为止你尝试了哪种风格?

标签: python css ubuntu gtk


【解决方案1】:

取自Why css style don't work on GtkButton?

cssProvider = Gtk.CssProvider()
cssProvider.load_from_path('style.css')
screen = Gdk.Screen.get_default()
styleContext = Gtk.StyleContext()
styleContext.add_provider_for_screen(screen, cssProvider,
Gtk.STYLE_PROVIDER_PRIORITY_USER) # With the others GTK_STYLE_PROVIDER_PRIORITY values get the same result.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-23
    • 1970-01-01
    • 2015-07-13
    相关资源
    最近更新 更多