comparison sat/tools/common/template_xmlui.py @ 2669:bdb8276fd2da

frontends (xmlui): class_map is now an arg of create function: class_map was so far used as a global value, but in some cases, several XMLUI managers may be used (it's the case in Cagou's remote controllers plugins, template_xmlui is used to manage remotes). This patch set class_map as a create argument, this way it can be set with partial, and several XMLUI managers can be instanced at the same time.
author Goffi <goffi@goffi.org>
date Fri, 31 Aug 2018 16:03:12 +0200
parents 56f94936df1e
children 003b8b4b56a7
comparison
equal deleted inserted replaced
2668:c274201cea94 2669:bdb8276fd2da
24 24
25 from sat.core.log import getLogger 25 from sat.core.log import getLogger
26 26
27 log = getLogger(__name__) 27 log = getLogger(__name__)
28 from sat_frontends.tools import xmlui 28 from sat_frontends.tools import xmlui
29 from functools import partial
29 30
30 31
31 ## Widgets ## 32 ## Widgets ##
32 33
33 34
174 175
175 ## Factory ## 176 ## Factory ##
176 177
177 178
178 class WidgetFactory(object): 179 class WidgetFactory(object):
180
179 def __getattr__(self, attr): 181 def __getattr__(self, attr):
180 if attr.startswith("create"): 182 if attr.startswith("create"):
181 cls = globals()[attr[6:]] 183 cls = globals()[attr[6:]]
182 return cls 184 return cls
183 185
197 199
198 def __init__(*args, **kwargs): 200 def __init__(*args, **kwargs):
199 raise NotImplementedError 201 raise NotImplementedError
200 202
201 203
202 xmlui.registerClass(xmlui.CLASS_PANEL, XMLUIPanel) 204 create = partial(xmlui.create, class_map={
203 xmlui.registerClass(xmlui.CLASS_DIALOG, XMLUIDialog) 205 xmlui.CLASS_PANEL: XMLUIPanel,
204 create = xmlui.create 206 xmlui.CLASS_DIALOG: XMLUIDialog})