# HG changeset patch # User Goffi # Date 1281587505 -28800 # Node ID 2ea8dab08160bf03eca9c5f67d8c23323fe00d6a # Parent 06985b6ad23a7d691dd3748a7de850c4922f9b74 Primitivus: XMLUI's show method now manage window and popup diff -r 06985b6ad23a -r 2ea8dab08160 frontends/primitivus/xmlui.py --- a/frontends/primitivus/xmlui.py Thu Aug 12 12:30:36 2010 +0800 +++ b/frontends/primitivus/xmlui.py Thu Aug 12 12:31:45 2010 +0800 @@ -55,6 +55,7 @@ self.title = title self.options = options self.misc = misc + self.__dest = "window" self.ctrl_list = {} # usefull to access ctrl widget = self.constructUI(xml_data) urwid.WidgetWrap.__init__(self,widget) @@ -151,8 +152,7 @@ cat_dom = minidom.parseString(xml_data.encode('utf-8')) top=cat_dom.documentElement self.type = top.getAttribute("type") - if not self.title: - self.title = top.getAttribute("title") #TODO: manage title + self.title = top.getAttribute("title") or self.title if top.nodeName != "sat_xmlui" or not self.type in ['form', 'param', 'window']: raise InvalidXMLUI @@ -185,10 +185,20 @@ ret_wid.addFooter(grid_wid) return ret_wid - def show(self): - """Show the constructed UI""" + def show(self,show_type = 'popup'): + """Show the constructed UI + @param show_type: how to show the UI: + - popup + - window""" + self.__dest = "popup" decorated = custom_widgets.LabelLine(self, custom_widgets.SurroundedText(self.title or '')) - self.host.showPopUp(decorated) + if show_type == 'popup': + self.host.showPopUp(decorated) + elif show_type == 'window': + self.host.addWindow(decorated) + else: + error(_('INTERNAL ERROR: Unmanaged show_type (%s)') % show_type) + assert(False) self.host.redraw() @@ -230,7 +240,10 @@ self.host.removePopUp() def onFormCancelled(self, button): - self.host.removePopUp() + if self.__dest == 'window': + self.host.removeWindow() + else: + self.host.removePopUp() def onSaveParams(self, button): for ctrl in self.param_changed: