2016-11-04 20:03:12 +00:00
|
|
|
import importlib
|
|
|
|
import bumblebee.theme
|
2016-11-04 20:41:22 +00:00
|
|
|
import bumblebee.output
|
2016-11-05 05:47:22 +00:00
|
|
|
import bumblebee.modules
|
2016-11-04 20:03:12 +00:00
|
|
|
|
|
|
|
class Engine:
|
2016-11-05 07:11:08 +00:00
|
|
|
def __init__(self, config):
|
2016-11-04 20:03:12 +00:00
|
|
|
self._modules = []
|
2016-11-05 07:11:08 +00:00
|
|
|
self._config = config
|
|
|
|
self._theme = bumblebee.theme.Theme(config)
|
|
|
|
self._output = bumblebee.output.output(config)
|
2016-11-04 20:03:12 +00:00
|
|
|
|
2016-11-05 13:26:02 +00:00
|
|
|
def load_module(self, modulespec):
|
|
|
|
name = modulespec["name"]
|
2016-11-04 20:03:12 +00:00
|
|
|
module = importlib.import_module("bumblebee.modules.{}".format(name))
|
2016-11-05 13:26:02 +00:00
|
|
|
return getattr(module, "Module")(self._output, self._config, modulespec["alias"])
|
2016-11-04 20:03:12 +00:00
|
|
|
|
|
|
|
def load_modules(self):
|
2016-11-05 07:11:08 +00:00
|
|
|
for m in self._config.modules():
|
2016-11-04 20:03:12 +00:00
|
|
|
self._modules.append(self.load_module(m))
|
|
|
|
|
|
|
|
def run(self):
|
2016-11-05 07:59:43 +00:00
|
|
|
self._output.start()
|
2016-11-04 20:03:12 +00:00
|
|
|
|
|
|
|
while True:
|
2016-11-05 07:59:43 +00:00
|
|
|
self._theme.begin()
|
2016-11-04 20:03:12 +00:00
|
|
|
for m in self._modules:
|
2016-11-05 07:59:43 +00:00
|
|
|
self._output.draw(m.widgets(), self._theme)
|
|
|
|
self._output.flush()
|
|
|
|
self._output.wait()
|
2016-11-04 20:03:12 +00:00
|
|
|
|
2016-11-05 07:59:43 +00:00
|
|
|
self._output.stop()
|
2016-11-04 20:03:12 +00:00
|
|
|
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|