2 # -*- coding: utf-8 -*-
4 # ------------------------------------------------------------
5 # notification_dialog.pyw
7 # the user should give us a notification
9 # Autor: Oliver Maurhart, <oliver.maurhart@ait.ac.at>
11 # Copyright 2013-2014 X-Net and AIT Austrian Institute of Technology
18 # https://www.x-net.at
20 # AIT Austrian Institute of Technology
21 # Donau City Strasse 1
24 # http://www.ait.ac.at
27 # Licensed under the Apache License, Version 2.0 (the "License");
28 # you may not use this file except in compliance with the License.
29 # You may obtain a copy of the License at
31 # http://www.apache.org/licenses/LICENSE-2.0
33 # Unless required by applicable law or agreed to in writing, software
34 # distributed under the License is distributed on an "AS IS" BASIS,
35 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36 # See the License for the specific language governing permissions and
37 # limitations under the License.
38 # ------------------------------------------------------------
41 # ------------------------------------------------------------
46 from PyQt4 import QtCore
47 from PyQt4 import QtGui
49 from ui_NotificationDialog import Ui_NotificationDialog
50 from about_dialog import AboutDialog
53 # ------------------------------------------------------------
57 class NotificationDialog(QtGui.QDialog):
59 """A dialog for letting the user pass on a user/notification combo"""
61 def __init__(self, caption = 'OpenSecurity Notification', message = 'This is a notification from the OpenSecurity System.'):
63 QtGui.QDialog.__init__(self)
65 # setup the user interface
66 self.ui = Ui_NotificationDialog()
68 self.setWindowTitle(caption)
71 self._about_dialog = AboutDialog()
74 self.ui.lblMessage.setText(message)
75 self.ui.btnAbout.clicked.connect(self.clicked_about)
76 self.ui.btnOk.clicked.connect(self.accept)
78 # positionate ourself central
79 screen = QtGui.QDesktopWidget().screenGeometry()
80 size = self.geometry()
81 self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2)
84 def clicked_about(self):
86 """About button has been clicked."""
87 self._about_dialog.show()
92 """Ok button has been clicked."""
93 sys.stdout.write('{ ')
94 sys.stdout.write('\'notification\': \'')
95 sys.stdout.write(self.ui.edtNotification.text())
96 sys.stdout.write('\' ')
97 sys.stdout.write('}\n')
101 def set_user_text(user_text):
103 """Set a text to explain which notification we need."""
104 self.ui.lblText.setText(user_text)
107 if __name__ == "__main__":
108 a = QtGui.QApplication(sys.argv)
109 d = NotificationDialog()