How to install Gtk Icon Theme with PYGtk?

How to set global system icon using Python (PYGtk 3)?

This returns the current topic topic in the system. It works great.

from gi.repository import Gtk, GObject, Gio, GLib
print(Gtk.Settings.get_default().get_property("gtk-icon-theme-name"))

But I can’t install it. I tried this, but with no result:

from gi.repository import Gtk, GObject, Gio, GLib
Gtk.Settings.get_default().set_property("gtk-icon-theme-name", "Numix")

Thank!

+4
source share
1 answer

You need to verify that the theme directory you want exists in /path/to/Python/x.x/Lib/site-packages/gnome/share/themes/.

Then, before the / script program initializes the Gtk window, set the theme:

from sys import stderr, exit
try:
    import gi
    gi.require_version('Gtk', '3.0')
    from gi.repository import Gtk, Gdk, GObject, Gio, GLib
except (ImportError, ImportWarning):
    stderr.write("Could not import GTK. Please install it.")

class HelloWindow(Gtk.Window):

    def __init__(self):
        Gtk.Settings.get_default().set_property("gtk-icon-theme-name", "Numix")
        Gtk.Settings.get_default().set_property("gtk-theme-name", "MS-Windows-XP")
        Gtk.Window.__init__(self, title="Hello World")
        ...
+1
source

All Articles