Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/JokeMachineActivity.py
diff options
context:
space:
mode:
authorAntoine van Gelder <antoine@g7.org.za>2007-10-29 12:27:03 (GMT)
committer Antoine van Gelder <antoine@g7.org.za>2007-10-29 12:27:03 (GMT)
commit02d20e71128f75bd755cb17914d53c62a04ee09e (patch)
treef74f490dafef48f95aa526125cb94430be1e2361 /JokeMachineActivity.py
parent9600c168b8b48676da556c63cd8597d71197ad43 (diff)
* Reverted alert fallback to pattern suggested by morgs
Diffstat (limited to 'JokeMachineActivity.py')
-rw-r--r--JokeMachineActivity.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/JokeMachineActivity.py b/JokeMachineActivity.py
index b572931..3259a9e 100644
--- a/JokeMachineActivity.py
+++ b/JokeMachineActivity.py
@@ -13,7 +13,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
-import os,sys
+import os
import logging
import gtk
@@ -52,7 +52,7 @@ from persistence.jokemachinestate import JokeMachineState
try:
from sugar.graphics.alert import NotifyAlert
except ImportError:
- import sys as NotifyAlert
+ pass
@@ -146,20 +146,18 @@ class JokeMachineActivity(activity.Activity):
self.set_page(pages.choose.Choose)
-
-
def alert(self, title, text=None):
'''Show an alert above the activity.'''
- if NotifyAlert is not sys:
+ try:
alert = NotifyAlert(timeout=10)
- alert.props.title = title
- alert.props.msg = text
- self.add_alert(alert)
- alert.connect('response', self.__alert_cancel_cb)
- alert.show()
- else:
+ except NameError:
logging.warning('sugar.graphics.alert.NotifyAlert not present for %r, %r', title, text)
-
+ return
+ alert.props.title = title
+ alert.props.msg = text
+ self.add_alert(alert)
+ alert.connect('response', self.__alert_cancel_cb)
+ alert.show()
def __alert_cancel_cb(self, alert, response_id):
'''Callback for alert events'''