1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
notifications = [ ]
notificationAdded = [ ]
# notifications which are currently on screen (and might be closed by similiar notifications)
current_notifications = [ ]
def __AddNotification(fnc, screen, id, *args, **kwargs):
notifications.append((fnc, screen, args, kwargs, id))
for x in notificationAdded:
x()
def AddNotification(screen, *args, **kwargs):
AddNotificationWithCallback(None, screen, *args, **kwargs)
def AddNotificationWithCallback(fnc, screen, *args, **kwargs):
__AddNotification(fnc, screen, None, *args, **kwargs)
def AddNotificationWithID(id, screen, *args, **kwargs):
__AddNotification(None, screen, id, *args, **kwargs)
# we don't support notifications with callback and ID as this
# would require manually calling the callback on cancelled popups.
def RemovePopup(id):
# remove similiar notifications
print "RemovePopup, id =", id
for x in notifications:
if x[4] and x[4] == id:
print "(found in notifications)"
notifications.remove(x)
for x in current_notifications:
if x[0] == id:
print "(found in current notifications)"
x[1].close()
def AddPopup(text, type, timeout, id = None):
if id is not None:
RemovePopup(id)
from Screens.MessageBox import MessageBox
print "AddPopup, id =", id
AddNotificationWithID(id, MessageBox, text = text, type = type, timeout = timeout)
|