Programmer info: Change system theme color into dark with 3 lines of python code

More
8 years 2 months ago #115332 by Grotius
Example normal system theme colors :

Attachment not found



Code:
import gtk self.settings = gtk.settings_get_default() self.settings.set_property("gtk-theme-name", "Adwaita-dark")

Example after 3 lines of code :

Attachment not found



There is no need for this :
themedir = "/usr/share/themes"
userthemedir = os.path.join(os.path.expanduser("~"), ".themes")

In Gscreen this code is for changing system theme, Gmoccapy uses almost the same code :
Code:
# get the system wide theme settings = gtk.settings_get_default() settings.props.gtk_button_images = True self.data.system_theme = settings.get_property("gtk-theme-name") # check for a local theme gtkrc file localtheme = os.path.join(CONFIGPATH,'%s_theme'%self.skinname) if os.path.exists(localtheme): print 'local theme path found' self.data.local_theme = 'Link to %s_theme'% self.skinname # make ~/.themes - quietly ignore the error if it exists try: os.makedirs(userthemedir) except OSError as exception: if exception.errno != errno.EEXIST: raise # create systemlink because one can't store themes in an arbitrary folder. if not os.path.exists(userthemedir+'/%s'%self.data.local_theme): os.symlink(localtheme,userthemedir+'/%s'%self.data.local_theme) settings = gtk.settings_get_default() settings.set_string_property("gtk-theme-name", self.data.local_theme, "") else: self.data.local_theme = None

Please Log in to join the conversation.

More
8 years 2 months ago #115368 by cmorley
This is because Gscreen and Gmoccapy allow you to have your special theme in the config folder rather then the system folder.
Some CNC themes are not suitable for the system.

Chris M

Please Log in to join the conversation.

Time to create page: 0.152 seconds
Powered by Kunena Forum