Primitivus: XMLUI's show method now manage window and popup

This commit is contained in:
Goffi 2010-08-12 12:31:45 +08:00
commit 1b14209814

View file

@ -55,6 +55,7 @@ class XMLUI(urwid.WidgetWrap):
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 @@ class XMLUI(urwid.WidgetWrap):
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 @@ class XMLUI(urwid.WidgetWrap):
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 @@ class XMLUI(urwid.WidgetWrap):
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: