[core/themes] Add module-specific themes

Allow module-specific theme information to overload "default"
configuration. I.e. it is now possible to have specific prefix or
postfix configurations for different modules. The module name is derived
for each widget from the module (__module__) from which it was
instantiated.

see #23
This commit is contained in:
Tobi-wan Kenobi 2016-12-08 12:44:52 +01:00
parent 562fd85ca2
commit 2fa8d7b778
6 changed files with 56 additions and 20 deletions

View file

@ -13,6 +13,7 @@ class Module(object):
this base class.
"""
def __init__(self, engine, widgets):
self.name = self.__module__.split(".")[-1]
self._widgets = []
if widgets:
self._widgets = widgets if isinstance(widgets, list) else [widgets]
@ -59,10 +60,14 @@ class Engine(object):
"""Start the event loop"""
self._output.start()
while self.running():
self._output.begin()
for module in self._modules:
module.update(module.widgets())
self._output.draw(widgets=module.widgets(), engine=self)
for widget in module.widgets():
widget.set_module(module)
self._output.draw(widget=widget, engine=self)
self._output.flush()
self._output.end()
if self.running():
time.sleep(1)