[core/output] Add widget drawing

Add basic drawing of widgets. Each module instance returns a list of
widgets using the widgets() method which is then forwarded to the draw()
method of the configured output.

see #23
This commit is contained in:
Tobi-wan Kenobi 2016-12-04 12:53:18 +01:00
parent 6f52825ef0
commit 712d958e18
5 changed files with 41 additions and 1 deletions

View file

@ -18,4 +18,15 @@ class I3BarOutput(object):
"""Finish i3bar protocol"""
sys.stdout.write("]\n")
def draw(self, widgets):
"""Draw a number of widgets"""
if not isinstance(widgets, list):
widgets = [widgets]
result = []
for widget in widgets:
result.append({
u"full_text": widget.text()
})
sys.stdout.write(json.dumps(result))
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4