diff browser_side/dialog.py @ 231:fab7aa366576

browser_side: dialogs take **kwargs arguments + unibox helper method - add the **kwargs arguments to the dialog classes, especially to pass the Width='xxx' setting - add a method getTargetAndData to UniBox, for external use and to get the message recipient and body without dealing with the target hooks, selected panels...
author souliane <souliane@mailoo.org>
date Tue, 08 Oct 2013 13:38:42 +0200
parents 67e24c342e7f
children dec76d4536ad
line wrap: on
line diff
--- a/browser_side/dialog.py	Tue Oct 08 13:57:35 2013 +0200
+++ b/browser_side/dialog.py	Tue Oct 08 13:38:42 2013 +0200
@@ -95,15 +95,16 @@
     def onCancel(self, sender):
         self.hide()
 
+
 class GenericConfirmDialog(DialogBox):
 
-    def __init__(self, widgets, callback, title='Confirmation'):
+    def __init__(self, widgets, callback, title='Confirmation', **kwargs):
         """
         Dialog to confirm an action
         @param callback: method to call when contacts have been choosed
         """
         self.callback = callback
-        DialogBox.__init__(self, centered=True)
+        DialogBox.__init__(self, centered=True, **kwargs)
 
         content = VerticalPanel()
         content.setWidth('100%')
@@ -129,21 +130,21 @@
 
 class ConfirmDialog(GenericConfirmDialog):
 
-    def __init__(self, callback, text='Are you sure ?', title='Confirmation'):
-        GenericConfirmDialog.__init__(self, [HTML(text)], callback, title)
+    def __init__(self, callback, text='Are you sure ?', title='Confirmation', **kwargs):
+        GenericConfirmDialog.__init__(self, [HTML(text)], callback, title, **kwargs)
 
 
 class GenericDialog(DialogBox):
     """Dialog which just show a widget and a close button"""
 
-    def __init__(self, title, main_widget, callback=None, options=None):
+    def __init__(self, title, main_widget, callback=None, options=None, **kwargs):
         """Simple notice dialog box
         @param title: HTML put in the header
         @param main_widget: widget put in the body
         @param callback: method to call on closing
         @param options: one or more of the following options:
                         - NO_CLOSE: don't add a close button"""
-        DialogBox.__init__(self, centered=True)
+        DialogBox.__init__(self, centered=True, **kwargs)
         self.callback = callback
         if not options:
             options = []
@@ -170,10 +171,12 @@
         if self.callback:
             self.callback()
 
+
 class InfoDialog(GenericDialog):
 
-    def __init__(self, title, body, callback = None, options = None):
-        GenericDialog.__init__(self, title, HTML(body), callback, options)
+    def __init__(self, title, body, callback=None, options=None, **kwargs):
+        GenericDialog.__init__(self, title, HTML(body), callback, options, **kwargs)
+
 
 class PopupPanelWrapper(PopupPanel):
     """This wrapper catch Escape event to avoid request cancellation by Firefox"""
@@ -184,6 +187,7 @@
             event.preventDefault()
         return PopupPanel.onEventPreview(self, event)
 
+
 class ExtTextBox(TextBox):
     """Extended TextBox"""