diff 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
line wrap: on
line diff
--- a/sat/tools/common/template_xmlui.py	Fri Aug 31 15:57:11 2018 +0200
+++ b/sat/tools/common/template_xmlui.py	Fri Aug 31 16:03:12 2018 +0200
@@ -26,6 +26,7 @@
 
 log = getLogger(__name__)
 from sat_frontends.tools import xmlui
+from functools import partial
 
 
 ## Widgets ##
@@ -176,6 +177,7 @@
 
 
 class WidgetFactory(object):
+
     def __getattr__(self, attr):
         if attr.startswith("create"):
             cls = globals()[attr[6:]]
@@ -199,6 +201,6 @@
         raise NotImplementedError
 
 
-xmlui.registerClass(xmlui.CLASS_PANEL, XMLUIPanel)
-xmlui.registerClass(xmlui.CLASS_DIALOG, XMLUIDialog)
-create = xmlui.create
+create = partial(xmlui.create, class_map={
+    xmlui.CLASS_PANEL: XMLUIPanel,
+    xmlui.CLASS_DIALOG: XMLUIDialog})