Search code examples
pygtk

PyGtk3 how to change application theme?


i tried rc_parse method using Gtk.rc_parse("path/to/Hooli/gtk-3/gtk.css") code but it is not working. this question is simlpy but solution of question not easy. how can i change the my gtk apllication theme ? or how can i use custom theme on my gtk application ?

Thanks.


Solution

  • import gi
    gi.require_version("Gtk", "3.0")
    from gi.repository import Gtk as gtk
    
    settings = gtk.Settings.get_default()
    settings.set_property("gtk-theme-name", "Numix")
    settings.set_property("gtk-application-prefer-dark-theme", False)  # if you want use dark theme, set second arg to True
    
    # getting all existing properties #
    
    for i in settings.list_properties():
        print(i)
    

    this codes working very correctly on windows, linux, ... i hope this solve your problem