Package qt_dialog_service ::
Module qt_dialog_service
|
|
1
2 import sys
3
4 from python_qt_binding import QtGui
5 from QtGui import QWidget, QErrorMessage, QMessageBox, QApplication
6
8 '''
9 Provides popup windows for information and error messages
10 '''
11
12
13
14
15
17 super(DialogService, self).__init__(parent);
18
19
20
21
22
23
24 self.errorMsgPopup = QErrorMessage.qtHandler();
25
26
27 self.errorMsgPopup.setParent(parent, self.errorMsgPopup.windowFlags());
28
29 self.infoMsg = QMessageBox(parent=parent);
30
31
32
33
34
35 QErrorMessage
37 '''
38 Given a string, pop up an error dialog on top of the application window.
39 @param errMsg: The message
40 @type errMsg: string
41 '''
42 self.errorMsgPopup.showMessage(errMsg);
43
44
45
46
47
49 '''
50 Display a message window with an OK button on top of the application window.
51 @param text: text to display
52 @type text: string
53 '''
54 self.infoMsg.setText(text);
55 self.infoMsg.exec_();
56
57 if __name__ == '__main__':
58
59
60 app = QApplication(sys.argv);
61 dservice = DialogService()
62 dservice.showErrorMsg("This is an error")
63 dservice.showInfoMsg("This is info")
64 app.exec_();
65 sys.exit();
66