I use the following to get a list of available themes, maybe it's useful:
import os
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gio
def get_themes():
theme_dir = Gtk.rc_get_theme_dir()
theme_dirs = [theme_dir, os.path.join(os.path.expanduser("~"),
".themes")]
themes = set()
for theme_dir in theme_dirs:
try:
subdirs = os.listdir(theme_dir)
except OSError:
continue
for dir_ in subdirs:
gtk_dir = os.path.join(theme_dir, dir_, "gtk-3.0")
if os.path.isdir(gtk_dir):
themes.add(dir_)
try:
resource_themes = Gio.resources_enumerate_children(
"/org/gtk/libgtk/theme", 0)
except GLib.GError:
pass
else:
themes.update([t.rstrip("/") for t in resource_themes])
return themes
_______________________________________________
python-hackers-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/python-hackers-list