我想用 GTK+ 3 和 Python 创建一个 Ubuntu 应用程序,但我是 GTK 的新手。
我在下图中有一个 gtkbox 的 css 样式,但是我如何将这种样式添加到我的 GtkBox/GtkVBox 对象中,使其与图像中的一样。
image of my concept
注意:这张图片是由 photoshop 创建的。
最佳答案
取自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.
关于python - 如何在 Gtk+ 3 中向 GtkBox 添加 css 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17675699/