frontends (xmlui): new widget_value dict to get first value of widget by name
This commit is contained in:
parent
d1a44e1501
commit
5a34d090b3
1 changed files with 19 additions and 0 deletions
|
|
@ -313,6 +313,20 @@ class XMLUIBase(object):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
|
class ValueGetter(object):
|
||||||
|
"""dict like object which return values of widgets"""
|
||||||
|
|
||||||
|
def __init__(self, widgets, attr='value'):
|
||||||
|
self.attr = attr
|
||||||
|
self.widgets = widgets
|
||||||
|
|
||||||
|
def __getitem__(self, name):
|
||||||
|
return getattr(self.widgets[name], self.attr)
|
||||||
|
|
||||||
|
def __getattr__(self, name):
|
||||||
|
return self.__getitem__(name)
|
||||||
|
|
||||||
|
|
||||||
class XMLUIPanel(XMLUIBase):
|
class XMLUIPanel(XMLUIBase):
|
||||||
"""XMLUI Panel
|
"""XMLUI Panel
|
||||||
|
|
||||||
|
|
@ -323,9 +337,14 @@ class XMLUIPanel(XMLUIBase):
|
||||||
widget_factory = None
|
widget_factory = None
|
||||||
|
|
||||||
def __init__(self, host, parsed_dom, title=None, flags=None, callback=None, profile=C.PROF_KEY_NONE):
|
def __init__(self, host, parsed_dom, title=None, flags=None, callback=None, profile=C.PROF_KEY_NONE):
|
||||||
|
"""
|
||||||
|
@property widgets(dict): widget name => widget map
|
||||||
|
@property widget_value(ValueGetter): retrieve widget value from it's name
|
||||||
|
"""
|
||||||
super(XMLUIPanel, self).__init__(host, parsed_dom, title=title, flags=flags, callback=callback, profile=profile)
|
super(XMLUIPanel, self).__init__(host, parsed_dom, title=title, flags=flags, callback=callback, profile=profile)
|
||||||
self.ctrl_list = {} # input widget, used mainly for forms
|
self.ctrl_list = {} # input widget, used mainly for forms
|
||||||
self.widgets = {} # allow to access any named widgets
|
self.widgets = {} # allow to access any named widgets
|
||||||
|
self.widget_value = ValueGetter(self.widgets)
|
||||||
self._main_cont = None
|
self._main_cont = None
|
||||||
self.constructUI(parsed_dom)
|
self.constructUI(parsed_dom)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue