Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply theme to PyGTK Application

Is it possible to apply this GTK+ theme in my PyGTK application?

Can I apply the theme programatically? Ie, to apply the theme do I use a PyGTK function or do I have to find where PyGTK is installed on my machine(Inside Python2.7) and change the arrow .pngs, and the scrollbar .pngs and etc.?

Note I only have PyGTK installed I dont have GTK+ installed, do I need that? Will the theme linked above work for PyGTK or only for GTK+?

Can you provide advice on how I can apply this theme to my PyGTK application?

like image 874
sazr Avatar asked Jun 06 '12 05:06

sazr


1 Answers

If you download the first package from your link, the one that's labelled "(GTK & Metacity themes)" you should get a tar.gz archive. Unpack the archive into some folder like /home/jake/.themes. Then in your pygtk code, before you initialize your widgets(I would do it right after you import pygtk and gtk in your code), add this line:

gtk.rc_parse('/home/jake/.themes/Elegant Brit/gtk-2.0/gtkrc')

That gtkrc file in that directory contains the information used to tell gtk how to draw the widgets for that theme.

Hope that helps.

Note: Theme choices should be left up to the user and it is generally frowned upon to change/modify the current user's theme when developing an application using gtk.

like image 186
Wes Avatar answered Sep 28 '22 04:09

Wes