alarmserver.test_alarmserver_model

Package alarmserver :: Module test_alarmserver_model |
[hide private]
[frames] | no frames]

# Source Code for Module alarmserver.test_alarmserver_model

     1  """
     2  Created on 28.10.2013
     3  @author: lehmann
     4
     5  """
     6  import sys
     7
     8  from PyQt4.QtCore import SIGNAL
     9  from PyQt4.QtGui import QWidget, QTableView, QHBoxLayout, QApplication, QPushButton
    10
    11  from gui import AlarmServerModel
    12
    13
    14 -class MainWindow(QWidget):
    15 -    def __init__(self, parent=None):
    16          super(MainWindow, self).__init__(parent)
    17
    18          self.alarmserverModel = AlarmServerModel()
    19          self.alarmserverModel.define_alarm(1, "alarm 1")
    20          self.alarmserverModel.define_alarm(2, "alarm 2")
    21          self.alarmserverModel.define_alarm(3, "alarm 3")
    22
    23          self.alarmTableView = QTableView()
    24          self.alarmTableView.setModel(self.alarmserverModel)
    25
    26          self.button1 = QPushButton("Raise Alarm 1")
    27          self.button2 = QPushButton("Acknowledge Alarm 1")
    28
    29          self.connect(self.button1, SIGNAL("pressed()"), self.raise_alarm1)
    30          self.connect(self.button2, SIGNAL("pressed()"), self.acknowledge_alarm1)
    31          layout = QHBoxLayout()
    32          layout.addWidget(self.alarmTableView)
    33          layout.addWidget(self.button1)
    34          layout.addWidget(self.button2)
    35          self.setLayout(layout)
    36
    37 -    def raise_alarm1(self):
    38          self.alarmserverModel.raise_alarm(1)
    39          self.alarmTableView.update()
    40
    41 -    def acknowledge_alarm1(self):
    42          self.alarmserverModel.acknowledge(1)
    43          self.alarmTableView.update()
    44
    45  if __name__ == "__main__":
    46      app = QApplication(sys.argv)
    47      frm = MainWindow()
    48      frm.show()
    49      app.exec_()
    50