# Class e.p.p.w.t.Theme(object):

Part of elisa.plugins.pigment.widgets.theme View In Hierarchy

A theme object, that adds styles to widgets properties and to stock resources.

A basic theme will be built from the default configuration files, providing necessary style information for the widgets: without that, widgets won't work.

Instance Variables | widget_styles | the styles for the widgets, for each state (type: dict of states to `elisa.plugins.pigment.widgets.Style`s )
| stock_resources | the map of resource names to file paths (type: a dict strings to strings )
| fallback_themes | a dictionary of plugin names to Themes, cashing information necessary to do the right fallback for missing resources (type: dictionary of strings to `elisa.core.components.theme.Theme` )

Line # | Kind | Name | Docs
--- | --- | --- | ---
57 | Method | __init__ | DOCME
149 | Class Method | load_from_module | Build a `elisa.plugins.pigment.widgets.Theme` object using the 'styles.conf'
193 | Method | update | Merge in-place another theme.
202 | Method | merge | Merge with another theme, returning a new one.
241 | Method | get_style_for_widget | Get the style for a widget class in the specified state.
265 | Method | get_resource | Get the named resources, doing a lookup into the plugins' defaults if not
285 | Method | lookup | Dynamically search for the named resource ('style' or 'resource').
335 | Method | __repr__ | Undocumented
343 | Class Method | get_default | Get the default theme.
353 | Static Method | set_default | Set the default theme.

def __init__(self, module_name=None, styles_conf=None, resources_conf=None):
DOCME

@classmethod
def load_from_module(cls, module_name):
Build a `elisa.plugins.pigment.widgets.Theme` object using the 'styles.conf' and 'resources.conf' files found in the specified module.

Parameters | module_name | the module to search, in the absolute dotted notation (type: string )
Returns | the new theme, or None (type: `elisa.plugins.pigment.widgets.Theme` )

def update(self, other):
Merge in-place another theme.

Parameters | other | the theme from which to update (type: `elisa.plugins.pigment.widgets.Theme` )

def merge(self, other, inplace=False):

Merge with another theme, returning a new one.

The new theme will have all the "properties" of the current style, with replaced values from the second, plus further "properties" coming from the other theme.

Parameters | other | the theme to merge (type: `elisa.plugins.pigment.widgets.Theme` )
| inplace | whether to build another theme, or update the current one
| inplate | (type: boolean )
Returns | the new theme (type: `elisa.plugins.pigment.widgets.Theme` )

def get_style_for_widget(self, widget, state=const.STATE_NORMAL, search=True):
Get the style for a widget class in the specified state.

Parameters | widget | the classname of the widget (type: string )
| state | the state for which we want to retrieve the style
| widget | (type: int (one of elisa.plugins.pigment.widgets.const.STATE_*) )
Returns | the associated style, or None (type: `elisa.plugins.pigment.widgets.Style` )

def get_resource(self, name, search=True):
Get the named resources, doing a lookup into the plugins' defaults if not found, or None.

Parameters | name | the name of the resource (type: string )
| search | (type: boolean )

def lookup(self, name, type, state=const.STATE_NORMAL):

    Dynamically search for the named resource ('style' or 'resource').

    If a suitable module is found during the search, a Theme object will be
    built and cached for later use: it will be stored in a dictionary
    indexed by absolute module names (in the Python dotted notation).

    @param name: the full qualified name to look for
                 (eg.: 'elisa.plugins.pigment.widgets.Button'
                  or 'elisa.plugins.shelf.icon')
    @type name: string
    @param type: 'style' or 'resource'
    @type type: Enum(['style', 'resource'])
    @param state: the state of the widget. Only used if type == 'style'
    @type state: Enum([state for state in const.STATE_*])
    @returns: the found resource (filepath or style), if any
    @rtype: string, or L{elisa.plugins.pigment.widgets.Style}, or None

def __repr__(self):
Undocumented
@classmethod
def get_default(cls):
Get the default theme.

@staticmethod
def set_default(theme):
Set the default theme.