# HG changeset patch # User Goffi # Date 1614447565 -3600 # Node ID 1f1741dc3cc4b1d45d751ce1bb5c745c8b49b88d # Parent cc065c13052c24283fe690c1eca3c535d03ffb33 frontends (tools/xmui): implement `ValueGetter.items` and `XMLUIPanel.values` to get a map from widget name to values diff -r cc065c13052c -r 1f1741dc3cc4 sat_frontends/tools/xmlui.py --- a/sat_frontends/tools/xmlui.py Sat Feb 27 18:37:43 2021 +0100 +++ b/sat_frontends/tools/xmlui.py Sat Feb 27 18:39:25 2021 +0100 @@ -364,6 +364,7 @@ class ValueGetter(object): """dict like object which return values of widgets""" + # FIXME: widget which can keep multiple values are not handled def __init__(self, widgets, attr="value"): self.attr = attr @@ -378,6 +379,17 @@ def keys(self): return list(self.widgets.keys()) + def items(self): + for name, widget in self.widgets.items(): + try: + value = widget.value + except AttributeError: + try: + value = list(widget.values) + except AttributeError: + continue + yield name, value + class XMLUIPanel(XMLUIBase): """XMLUI Panel @@ -426,6 +438,11 @@ def main_cont(self): return self._main_cont + @property + def values(self): + """Dict of all widgets values""" + return dict(self.widget_value.items()) + @main_cont.setter def main_cont(self, value): if self._main_cont is not None: