[core] Add (partial) support for states
Add states to the modules and widgets. Widgets are mostly just a pass-through (backwards compatibility, and ease of use - making states directly inside the widgets would require more code inside the modules to ensure that each widget is correctly updated). Still missing: - Separators during partial update (right now, it takes one interval until separators are drawn correctly)
This commit is contained in:
parent
fd57af9325
commit
84833dc7db
5 changed files with 27 additions and 3 deletions
|
@ -61,7 +61,9 @@ class Theme(object):
|
|||
self.__current.clear()
|
||||
|
||||
def __get(self, widget, key, default=None):
|
||||
if widget and isinstance(widget, str):
|
||||
if not widget:
|
||||
widget = core.widget.Widget('')
|
||||
if isinstance(widget, str):
|
||||
# special handling
|
||||
if widget == 'previous':
|
||||
return self.__previous.get(key, None)
|
||||
|
@ -75,6 +77,11 @@ class Theme(object):
|
|||
tmp = tmp[self.__widget_count % len(tmp)]
|
||||
value = tmp.get(key, value)
|
||||
|
||||
if not key in widget.state():
|
||||
for state in widget.state():
|
||||
theme = self.__get(widget, state, {})
|
||||
value = theme.get(key, value)
|
||||
|
||||
self.__current[key] = value
|
||||
return value
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue