diff browser_side/dialog.py @ 39:305e81c7a32c

Tarot game: a game can now be finished
author Goffi <goffi@goffi.org>
date Sun, 22 May 2011 00:15:01 +0200
parents 6b8da70b0799
children 7782a786b2f0
line wrap: on
line diff
--- a/browser_side/dialog.py	Thu May 19 02:00:59 2011 +0200
+++ b/browser_side/dialog.py	Sun May 22 00:15:01 2011 +0200
@@ -81,3 +81,31 @@
     def onCancel(self):
         self.hide()
 
+class ConfirmDialog(DialogBox):
+
+    def __init__(self, callback, text='Are you sure ?'):
+        """
+        Dialog to confirm an action
+        @param callback: method to call when contacts have been choosed
+        """
+        self.callback = callback
+        DialogBox.__init__(self, centered=True)
+
+        content = VerticalPanel()
+        content.setWidth('100%')
+        button_panel = HorizontalPanel()
+        self.confirm_button = Button("OK", self.onConfirm)
+        button_panel.add(self.confirm_button)
+        button_panel.add(Button("Cancel", self.onCancel))
+        content.add(button_panel)
+        self.setHTML(text)
+        self.setWidget(content)	
+    
+    def onConfirm(self):
+        self.hide()
+        self.callback(True)
+
+    def onCancel(self):
+        self.hide()
+        self.callback(False)
+