Module Theme
[hide private]
[frames] | no frames]

Module Theme

source code

The Blender.Window.Theme submodule.

Theme

This module provides access to Theme objects in Blender.

Example:

 # this is a simplified version of the save_theme.py script
 # shipped with Blender:
 import Blender
 from Blender.Window import Theme, FileSelector

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

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

   f = file(filename, "w")

   f.write("import Blender")
   f.write("from Blender.Window import Theme")
   f.write("theme = Theme.New('%s')" % theme.name)

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

     for var in vars: # write each variable from each theme space
       v = "%s.%s" % (tsp, var)
       exec("value = %s" % v)
       f.write("%s = %s\n" % (v, value))

   f.write('\nBlender.Redraw(-1)') # redraw to update the screen
   f.close()

 FileSelector(write_theme, "Save Current Theme", default_fname)
Classes [hide private]
  Theme
This object gives access to Themes in Blender.
  ThemeUI
This can be accessed with theme.get(t), where t can be 'ui' or -1.
  ThemeSpace
There is a sub-theme for each space in Blender (except for the Scripts window, but it will be added soon).
Functions [hide private]
Blender Theme
New(name='New Theme', theme='<default>')
Create a new Theme object.
source code
Blender Theme or a list of Blender Themes
Get(name=None)
Get the Theme object(s) from Blender.
source code
Variables [hide private]
  __package__ = None
Function Details [hide private]

New(name='New Theme', theme='<default>')

source code 

Create a new Theme object.

Parameters:
  • name (string) - The name of the new theme.
  • theme (Blender Theme) - a base theme to copy all data from. It defaults to the current one.
Returns: Blender Theme
A new Blender Theme object.

Get(name=None)

source code 

Get the Theme object(s) from Blender.

Parameters:
  • name (string) - The name of the Theme object.
Returns: Blender Theme or a list of Blender Themes
It depends on the name parameter:
  • (name): The Theme object called name, None if not found;
  • (): A list with all Theme objects currently in Blender.