File: messageBox.py

package info (click to toggle)
aptoncd 0.1-1.2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,572 kB
  • ctags: 544
  • sloc: python: 3,125; xml: 1,216; makefile: 125; sh: 6
file content (74 lines) | stat: -rw-r--r-- 2,486 bytes parent folder | download
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import gtk
import msg

(DOWNLOAD_FINISHED, CREATE_FINISHED) =range(2)
class MessageBox:
    
    def ShowInfo(self, text = '', parentWindow= None):
        dlg = gtk.MessageDialog(parentWindow, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, text)
        dlg.set_markup(text)
        dlg.run()
        dlg.destroy()
        return
  
    def ShowError(self, text = '', parentWindow= None):
        dlg= gtk.MessageDialog(parentWindow, gtk.DIALOG_MODAL,    gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, text)
        dlg.set_markup(text)
        dlg.run()
        dlg.destroy()
        return
        
    def ShowQuestionOkCancel(self,text, parentWindow= None):
        dlg = gtk.MessageDialog (parentWindow, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK_CANCEL, text)
        dlg.set_markup(text)
        response = dlg.run ()
        dlg.destroy ()
        
        return (response == gtk.RESPONSE_OK)
        
    def ShowQuestion(self,text, parentWindow= None):
        dlg = gtk.MessageDialog (parentWindow, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, text)
        dlg.set_markup(text)
        response = dlg.run ()
        dlg.destroy ()
        
        return (response == gtk.RESPONSE_YES)

    def ShowFinished(self,gladeFile,filePath):
        a = BurnCreateMsg(gladeFile,filePath)
        result =  a.run()
        return result, a.checked()

class BurnCreateMsg:
    def __init__(self, gladeFileName,filepath =''):
        self.formName = "frmDownloadFinished"
        self.filepath = filepath
        self.gladeFile = gtk.glade.XML(gladeFileName, self.formName)
        self.__checked = False
    
    def checked(self):
        return self.__checked
    
    def run(self):
        """This function will show the aboutDialog"""
        #Get the actual dialog widget
        frmMsg = self.gladeFile.get_widget(self.formName)
        frmMsg.set_position(gtk.WIN_POS_CENTER)
        frmMsg.set_modal(True)
        
        self.lblMsg = self.gladeFile.get_widget("lblMsg")
        self.ckboxRemoveTemp = self.gladeFile.get_widget("ckboxRemoveTemp")
        
        self.lblMsg.set_markup(msg.MESSAGE_0068 % self.filepath)           
            
        #run the dialog and store the response        
        result = frmMsg.run()
        
        self.__checked = self.ckboxRemoveTemp.get_active() 
        #we are done with the dialog, destory it
        frmMsg.destroy()
        
        #return the result
        return     result