diff browser_side/dialog.py @ 48:153de5d461a4

added Social Contract \o. (in French only so far) - new infoDialog, to show widget, it's used here to show an external webpage - some CSS tuning
author Goffi <goffi@goffi.org>
date Thu, 26 May 2011 18:44:31 +0200
parents a7ff1e6f1229
children f1d2eb9b2523
line wrap: on
line diff
--- a/browser_side/dialog.py	Thu May 26 17:17:48 2011 +0200
+++ b/browser_side/dialog.py	Thu May 26 18:44:31 2011 +0200
@@ -26,6 +26,7 @@
 from pyjamas.ui.ListBox import ListBox
 from pyjamas.ui.Button import Button
 from pyjamas.ui.HTML import HTML
+from pyjamas.ui import HasAlignment
 from pyjamas.ui.KeyboardListener import KEY_ESCAPE
 
 class ContactsChooser(DialogBox):
@@ -112,27 +113,36 @@
         self.hide()
         self.callback(False)
 
-class SimpleDialog(DialogBox):
+class InfoDialog(DialogBox):
+    """Dialog which just show a widget and a close button"""
 
-    def __init__(self, title, body, callback = None):
+    def __init__(self, title, widget, callback = None):
         """Simple notice dialog box
         @param title: HTML put in the header
-        @param body: HTML put in the body"""
+        @param body: widget put in the body"""
         DialogBox.__init__(self, centered=True)
         self.callback = callback
         _body = VerticalPanel()
+        _body.setSize('100%','100%')
+        _body.setHorizontalAlignment(HasAlignment.ALIGN_CENTER)
         _body.setSpacing(4)
-        _body.add(HTML(body))
+        _body.add(widget)
+        _body.setCellWidth(widget, '100%')
         _body.add(Button("Close", self.onClose))
-        _body.setStyleName("dialogBody")
         self.setHTML(title)
         self.setWidget(_body)
+        self.panel.setWidth('100%')
 
     def onClose(self):
         self.hide()
         if self.callback:
             self.callback()
 
+class SimpleDialog(InfoDialog):
+
+    def __init__(self, title, body, callback = None):
+        InfoDialog.__init__(self, title, HTML(body), callback)
+
 class PopupPanelWrapper(PopupPanel):
     """This wrapper catch Escape event to avoid request cancellation by Firefox"""