Featured post

new redirect for blender.org bpy docs.

http://www.blender.org/api/blender_python_api_current/ As of 10/11 november 2015 we can now link to the current api docs and not be worr...

November 07, 2014

TextEditor Theme colours

Everyone has their own ideas about themes, for text editor I find this theme quite relaxing even when using flux (which dims and extracts greens and blues after sundown)
import json
import bpy
from mathutils import Color, Vector
current_theme = bpy.context.user_preferences.themes.items()[0][0]
texed = bpy.context.user_preferences.themes[current_theme].text_editor
theme_options = {
'space.text',
'space.back',
'cursor',
'syntax_builtin', # import, return, for, in..
'syntax_comment',
'syntax_numbers',
'syntax_special', # def, class..
'syntax_string',
'syntax_symbols', # = ()[] . , > < == etc.
'syntax_reserved',
'syntax_preprocessor',
'line_numbers_background',
'selected_text'
}
theme_dict = {}
for opt in theme_options:
if '.' in opt:
# assume only one dot.
prime, subprime = opt.split('.')
val = getattr(getattr(texed, prime), subprime)
else:
val = getattr(texed, opt)
# cant round a colour, convert to vector first.
regular_vec = Vector(val[:])
# rounds the value after 7th decimal
theme_dict[opt] = regular_vec.to_tuple(7)
m = json.dumps(theme_dict, sort_keys=True, indent=2)
print(m)


Mine looks like this

I guess one might want to save this a json and also write a simple importer.