python gtk 深色主题图标按钮

python gtk dark theme icon buttons

将我的 Cinnamon 桌面上的主题更改为深色主题 (Adwaita-dark) 后,我之前编写的一个程序现在显示的按钮不正确。虽然例如在文件管理器等其他程序中,图标的颜色现在是白色的,它们在这里保持黑色。

我使用 Gtk.Button.new_from_icon_name() 创建了这些按钮:

import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk

...

button = Gtk.Button.new_from_icon_name("document-new", 1)

有没有办法让它们的颜色自动适应当前活动的主题?

我遇到了同样的问题,最后我使用了 *-symbolic 版本的图标。 根据Gnome docs

In the GNOME 3 designs we have identified a number of places where using a symbolic variant of a standard icon is desirable. Symbolic icons are usually low color or monochrome and intended to match the foreground font color. They may be used where a high color, detailed representation isn't warranted.

这意味着您更愿意使用

button = Gtk.Button.new_from_icon_name("document-new-symbolic", 1)