import os from PyQt4 import QtGui, QtCore, uic from labels import cm base_dir = os.path.dirname(os.path.realpath(__file__)) class StatusWidget(QtGui.QWidget): def __init__(self, main_window, device, parent=None): QtGui.QWidget.__init__(self, parent) uic.loadUi("%s/ui/status.ui" % base_dir, self) self.main_window = main_window self.units = self.main_window.units self.addAttribute = lambda dev, attr: self.main_window.addAttribute(dev, attr) self.device = device self.IDLabel.setText(device) self.StateLabel.setModel(device) self.InterlockLabel.setModel(device, "FOFBIlk") self.IDLabel.setText(device) self.FOFBStateLabel.setModel(device, "FOFBState") self.FOFBStateLabel.setColorMap(cm.FOFB_STATE) # self.BuffersLabel.setModel() self.S1Label.setModel(device, "FOFBSaturation", 0) self.S1Label.setColorMap(cm.RED_BOOL) self.S2Label.setModel(device, "FOFBSaturation", 1) self.S2Label.setColorMap(cm.RED_BOOL) self.S3Label.setModel(device, "FOFBSaturation", 2) self.S3Label.setColorMap(cm.RED_BOOL) self.S4Label.setModel(device, "FOFBSaturation", 3) self.S4Label.setColorMap(cm.RED_BOOL) self.connect(self.InterlockResetButton, QtCore.SIGNAL("clicked()"), lambda: self.main_window.execute_ireg_command(device, "FOFBIlkReset") ) self.connect(self.ReconnectButton, QtCore.SIGNAL("clicked()"), lambda: self.main_window.execute_ireg_command(device, "FOFBReconnect") ) self.connect(self.ResetPIButton, QtCore.SIGNAL("clicked()"), lambda: self.main_window.execute_ireg_command(device, "FOFBPIReset") ) self.connect(self.SaturationResetButton, QtCore.SIGNAL("clicked()"), lambda: self.main_window.execute_ireg_command(device, "FOFBSaturationReset") ) def update(self, cache): self.emit(QtCore.SIGNAL("update"), cache)