Welcome to mirror list, hosted at ThFree Co, Russian Federation.

save_theme.py « scripts « release - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 73c23087cec234af30150a0184ee069ccbf10608 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!BPY

"""
Name: 'Save Current Theme'
Blender: 234
Group: 'Help'
Tooltip: 'Save current theme as a bpython script'
"""

# $Id$
#
# --------------------------------------------------------------------------
# save_theme version 2.34 Sep 20, 2004
# Copyright (C) 2004: Willian P. Germano, wgermano _at_ ig.com.br
# --------------------------------------------------------------------------
# Released under the Blender Artistic License (BAL):
#   http://download.blender.org/documentation/html/x21254.html
#
# The scripts generated by this script are put under Public Domain by
# default, but you are free to edit the ones you generate with this script
# and change their license to another one of your choice.
# --------------------------------------------------------------------------

import Blender
from Blender.Window import Theme, FileSelector

theme = Theme.Get()[0] # get current theme

# default filename: theme's name + '_theme.py' in user's scripts dir:
default_fname = Blender.Get("scriptsdir")
default_fname = Blender.sys.join(default_fname, theme.name + '_theme.py')

def write_theme(filename):
	"Write the current theme as a bpython script"

	if filename.find('.py', -3) <= 0: filename += '.py'

	fout = file(filename, "w")

	fout.write("""#!BPY

\"\"\"
Name: '%s'
Blender: 234
Group: 'Theme'
Tooltip: 'Change current theme'
\"\"\"

# This script was automatically generated by the save_theme.py bpython script.
# By default, these generated scripts are released as Public Domain, but you
# are free to change the license of the scripts you generate with
# save_theme.py before releasing them.

import Blender
from Blender.Window import Theme

theme = Theme.New('%s')
""" % (theme.name, theme.name))

	for tsp in theme.get(): # 
		command = "\n%s = theme.get('%s')" % (tsp, tsp)
		fout.write(command + "\n")
		exec(command)
		exec("vars = dir(%s)" % tsp)
		vars.remove('theme')

		for var in vars:
			v = "%s.%s" % (tsp, var)
			exec("value = %s" % v)
			fout.write("%s = %s\n" % (v, value))

	fout.write('\nBlender.Redraw(-1)')
	fout.close()

FileSelector(write_theme, "Save Current Theme", default_fname)