[core] Added min-width and alignment themeing

Added theme-options ("minwidth" and "align") for setting the minimum
width and the alignment of a widget.

Also, allow widget to provide defaults for the theme options by setting
an attribute in their store called "theme-<name of the theme option>".

For example, a widget can now define a default alignment by using:
widget.set("theme-align", "default-value").
This commit is contained in:
Tobias Witek 2017-04-22 08:24:52 +02:00
parent a9a6bcd015
commit 92be7d3020
2 changed files with 11 additions and 0 deletions

View file

@ -74,6 +74,14 @@ class Theme(object):
"""Return the background color for this widget"""
return self._get(widget, "bg", None)
def align(self, widget):
"""Return the widget alignment"""
return self._get(widget, "align", None)
def minwidth(self, widget):
"""Return the minimum width string for this widget"""
return self._get(widget, "minwidth", "")
def separator(self, widget):
"""Return the separator between widgets"""
return self._get(widget, "separator", None)
@ -131,6 +139,7 @@ class Theme(object):
state_themes.append(self._get(widget, state, {}))
value = self._defaults.get(name, default)
value = widget.get("theme-{}".format(name), value)
value = self._cycle.get(name, value)
value = module_theme.get(name, value)