python - 如何在 Gtk+ 3 中向 GtkBox 添加 css 样式

标签 python css ubuntu gtk

我想用 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/

相关文章:

python - 如何处理 Docker 内的 FFMPEG 模块缺少探针?

python - python For循环中跳过错误的方法

python - 如何在python2.7中安装python black工具

Python:使用线程求解多个线性系统

html - 外部样式表中的样式不起作用。也许网站没有加载样式表。但为什么?

r - 在 ubuntu 虚拟机中安装 devtools 包

python - 将文件下载到特定文件夹 python

javascript - 单击div时如何使文本出现和消失?

html - 使用css悬停效果图像

python - 在 Ubuntu 上编译 cx_Freeze 时出错