[core/themes] Add state themes

Each widget can now return a state using the method "state()". This
string is then used to look up a theme information which is used instead
of the default or module theme, if found.

see #23
This commit is contained in:
Tobi-wan Kenobi 2016-12-09 13:32:22 +01:00
parent 88b36417f8
commit 4baf63f88c
5 changed files with 50 additions and 13 deletions

View file

@ -113,10 +113,16 @@ class Theme(object):
self._cycle = self._cycles[self._cycle_idx]
module_theme = self._theme.get(widget.module, {})
if name != widget.state():
# avoid infinite recursion
state_theme = self._get(widget, widget.state(), {})
else:
state_theme = {}
value = self._defaults.get(name, default)
value = self._cycle.get(name, value)
value = module_theme.get(name, value)
value = state_theme.get(name, value)
return value