Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranishmangal2002 <anishmangal2002@gmail.com>2010-07-02 19:26:37 (GMT)
committer Anish Mangal <anish@sugarlabs.org>2011-08-26 06:02:22 (GMT)
commitb60fe065605e34bced1dc82c8443286055399c89 (patch)
treecfc327ae1070b87252be12a69bcbaf005a8ed1dd
parentd8ad8fd0455f80c9f60be3fc2b18ad15afca1473 (diff)
Add ErrorAlert inherited from Alert
Adds the ErrorAlert class which is an alert inherited from the base Alert class. This is very similar to the ConfirmationAlert class with the difference being that it only displays an 'Ok' button in the Alert popup. Signed-off-by: anishmangal2002 <anishmangal2002@gmail.com> Signed-off-by: Anish Mangal <anish@sugarlabs.org>
-rw-r--r--src/sugar/graphics/alert.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/sugar/graphics/alert.py b/src/sugar/graphics/alert.py
index b4dfee1..4723833 100644
--- a/src/sugar/graphics/alert.py
+++ b/src/sugar/graphics/alert.py
@@ -290,6 +290,50 @@ class ConfirmationAlert(Alert):
self.add_button(gtk.RESPONSE_OK, _('Ok'), icon)
icon.show()
+class ErrorAlert(Alert):
+ """
+ This is a ready-made one button (Ok) alert.
+
+ An error alert is a nice shortcut from a standard Alert because it
+ comes with the 'OK' button already built-in. When clicked, the
+ 'OK' button will emit a response with a response_id of gtk.RESPONSE_OK.
+
+ Examples
+ --------
+
+ .. code-block:: python
+ from sugar.graphics.alert import ErrorAlert
+ ...
+ #### Method: _alert_error, create a Error alert (with ok
+ button standard)
+ # and add it to the UI.
+ def _alert_error(self):
+ alert = ErrorAlert()
+ alert.props.title=_('Title of Alert Goes Here')
+ alert.props.msg = _('Text message of alert goes here')
+ alert.connect('response', self._alert_response_cb)
+ self.add_alert(alert)
+
+
+ #### Method: _alert_response_cb, called when an alert object throws a
+ response event.
+ def _alert_response_cb(self, alert, response_id):
+ #remove the alert from the screen, since either a response button
+ #was clicked or there was a timeout
+ self.remove_alert(alert)
+
+ #Do any work that is specific to the response_id.
+ if response_id is gtk.RESPONSE_OK:
+ print 'Ok Button was clicked. Do any work upon ok here ...'
+
+ """
+
+ def __init__(self, **kwargs):
+ Alert.__init__(self, **kwargs)
+
+ icon = Icon(icon_name='dialog-ok')
+ self.add_button(gtk.RESPONSE_OK, _('Ok'), icon)
+ icon.show()
class _TimeoutIcon(hippo.CanvasText, hippo.CanvasItem):
"""An icon with a round border"""