diff tools/xml_tools.py @ 106:138d82f64b6f

plugin CS: friends parsing
author Goffi <goffi@goffi.org>
date Sat, 26 Jun 2010 15:33:16 +0800
parents d2630fba8dfd
children 5ae370c71803
line wrap: on
line diff
--- a/tools/xml_tools.py	Wed Jun 23 17:26:21 2010 +0800
+++ b/tools/xml_tools.py	Sat Jun 26 15:33:16 2010 +0800
@@ -88,9 +88,12 @@
                 assert(False)
             type = param.getAttribute('type')
             value = param.getAttribute('value') or None
-            callback = param.getAttribute('callback') or None
-            param_ui.addLabel(name)
-            param_ui.addElement(name=name, type=type, value=value, callback=callback)
+            callback_id = param.getAttribute('callback_id') or None
+            if type == "button":
+                param_ui.addEmpty()
+            else:
+                param_ui.addLabel(name)
+            param_ui.addElement(name=name, type=type, value=value, callback_id=callback_id)
 
     return param_ui.toXml()
 
@@ -200,15 +203,18 @@
         if value:
             elem.setAttribute('value', value)
 
-    def addButton(self, callback, name):
+    def addButton(self, callback_id, name, value):
         """Add a button
         @param callback: callback which will be called if button is pressed
-        @param name: name shown on the button"""
+        @param name: name
+        @param value: label of the button"""
         elem = self.__createElem('button', name, self.currentLayout)
-        elem.setAttribute('callback', callback)
+        elem.setAttribute('callback_id', callback_id)
+        if value:
+            elem.setAttribute('value', value)
 
     
-    def addElement(self, type, name = None, content = None, value = None, options = None, callback = None):
+    def addElement(self, type, name = None, content = None, value = None, options = None, callback_id = None):
         """Convenience method to add element, the params correspond to the ones in addSomething methods"""
         if type == 'empty':
             self.addEmpty(name)
@@ -224,8 +230,8 @@
         elif type == 'list':
             self.addList(options, name, value)
         elif type == 'button':
-            assert(callback and name)
-            self.addButton(callback, name)
+            assert(callback_id and value)
+            self.addButton(callback_id, name, value)
 
     def addOptions(self, options, parent):
         """Add options to a multi-values element (e.g. list)