diff frontends/src/wix/xmlui.py @ 802:9007bb133009

core, frontends: XMLUI refactoring: - XMLUI now use objects with 2 main classes: widgets (button, label, etc), and container which contain widgets according to a layout - widgets and containers classes are found through introspection, thereby it's really easy to add a new one - there is still the AddWidgetName helper, for example AddText('jid', 'test@example.net') will add a StringWidget with name "jid" and default value "test@example.net" - container can be inside other containers. changeContainer change the first parent container
author Goffi <goffi@goffi.org>
date Tue, 04 Feb 2014 18:19:00 +0100
parents 46aa5ada61bf
children f100fd8d279f
line wrap: on
line diff
--- a/frontends/src/wix/xmlui.py	Tue Feb 04 18:06:12 2014 +0100
+++ b/frontends/src/wix/xmlui.py	Tue Feb 04 18:19:00 2014 +0100
@@ -131,13 +131,6 @@
         return ret
 
 
-class AdvancedListWidget(ListWidget):
-    #TODO
-
-    def __init__(self, parent, options, flags):
-        super(ListWidget, self).__init__(parent, options, flags)
-
-
 class WixContainer(object):
     _xmlui_proportion = 1
 
@@ -185,7 +178,7 @@
             return cls
 
 
-class XMLUI(xmlui.XMLUI, wx.Frame, WixContainer):
+class XMLUI(xmlui.XMLUI, wx.Frame):
     """Create an user interface from a SàT XML"""
     widget_factory = WidgetFactory()
 
@@ -199,26 +192,25 @@
         self.sizer = wx.BoxSizer(wx.VERTICAL)
         self.SetSizer(self.sizer)
 
-        def postTreat(ret_wid):
+        def postTreat():
             if self.title:
                 self.SetTitle(self.title)
 
             if self.type == 'form':
                 dialogButtons = wx.StdDialogButtonSizer()
-                submitButton = wx.Button(ret_wid,wx.ID_OK, label=_("Submit"))
+                submitButton = wx.Button(self.main_cont,wx.ID_OK, label=_("Submit"))
                 dialogButtons.AddButton(submitButton)
-                ret_wid.Bind(wx.EVT_BUTTON, self.onFormSubmitted, submitButton)
+                self.main_cont.Bind(wx.EVT_BUTTON, self.onFormSubmitted, submitButton)
                 if not 'NO_CANCEL' in self.flags:
-                    cancelButton = wx.Button(ret_wid,wx.ID_CANCEL)
+                    cancelButton = wx.Button(self.main_cont,wx.ID_CANCEL)
                     dialogButtons.AddButton(cancelButton)
-                    ret_wid.Bind(wx.EVT_BUTTON, self.onFormCancelled, cancelButton)
+                    self.main_cont.Bind(wx.EVT_BUTTON, self.onFormCancelled, cancelButton)
                 dialogButtons.Realize()
-                ret_wid.sizer.Add(dialogButtons, flag=wx.ALIGN_CENTER_HORIZONTAL)
+                self.main_cont.sizer.Add(dialogButtons, flag=wx.ALIGN_CENTER_HORIZONTAL)
 
-            self._xmluiAppend(ret_wid)
+            self.sizer.Add(self.main_cont, 1, flag=wx.EXPAND)
             self.sizer.Fit(self)
             self.Show()
-            return ret_wid
 
         super(XMLUI, self).constructUI(xml_data, postTreat)
         if not 'NO_CANCEL' in self.flags:
@@ -251,5 +243,7 @@
         debug(_("close"))
         if self.type == 'param':
             self.onSaveParams()
+        else:
+            self._xmluiClose()
         event.Skip()