codiaf
codiaf

Reputation: 629

Change gtk application theme to a default with python and gtk 3

Is there a way I could tell my python 3 application to use for example always the Adwaita theme (Gnome 3 default theme) with GTK?

Upvotes: 0

Views: 1178

Answers (1)

andrewsomething
andrewsomething

Reputation: 2246

To force a specific Gtk theme, just load the css file:

win_style_context = self.get_style_context()
css_provider = Gtk.CssProvider()
css_provider.load_from_path("/usr/share/themes/Adwaita/gtk-3.0/gtk.css")
screen = Gdk.Screen.get_default()
win_style_context.add_provider_for_screen(screen, css_provider,
                                  Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

Upvotes: 2

Related Questions