root/src/alert.py @ 111

Revision 111, 1.7 KB (checked in by ecoughlan, 2 years ago)

Centering text

Line 
1'''
2Created on Feb 29, 2012
3
4@author: TechTrek
5'''
6from globals import *
7from window import *
8
9class Alert():
10    '''
11    A notification object that creates a window with the given text
12    '''
13
14
15    def __init__(self,text,options=False, optionResponse='windows'):
16        self.text = text
17        self.options = options
18        self.optionResponse = optionResponse
19
20    def displayAlert(self):
21        alertWindow = Window('alert',300,200)
22        alertWindow.setDefaultResponse(Response('windows',[],False,False))
23        alertIcon = WindowEntry(Response('windows',[],False,False))
24        alertIcon.addRectangle(Rectangle((0,0),500, 150,YELLOW))
25        alertIcon.addText(Text((10,20),'MESSAGE',32,FAKEBLACK))
26        alertIcon.addText(Text((30,60),self.text,24,FAKEBLACK,400))
27        alertWindow.addEntry(alertIcon)
28        if self.options == True:
29            okay = WindowEntry(Response(self.optionResponse,[],True,False))
30            okay.addRectangle(Rectangle((378,120),56,25,GRAY))
31            okay.addText(Text((378,125),'OKAY',24,FAKEBLACK,378+56,True,378))
32            alertWindow.addEntry(okay)
33            cancel = WindowEntry(Response('windows',[],True,False))
34            cancel.addRectangle(Rectangle((438,120),56,25,GRAY))
35            cancel.addText(Text((438,125),'CANCEL',24,FAKEBLACK,438+56,True,438))
36            alertWindow.addEntry(cancel)
37        else:
38            close = WindowEntry(Response('windows',[],True,False))
39            close.addRectangle(Rectangle((440,120),56,25,GRAY))
40            close.addText(Text((440,125),'CLOSE',24,FAKEBLACK,440+56,True,440))
41            alertWindow.addEntry(close)
42        return alertWindow
Note: See TracBrowser for help on using the browser.