def initComponents(self): self.setModal(True) macroServerLabel = Qt.QLabel("MacroServer:", self) self.macroServerComboBox = Qt.QComboBox() ms_stateIcons = self.__retriveMacroServersFromDB() self.__fillMacroServerComboBox(ms_stateIcons, self.macroServerComboBox) refreshMacroServersButton = Qt.QToolButton() refreshMacroServersButton.setDefaultAction( self.refreshMacroServersAction) doorLabel = Qt.QLabel("Door:", self) self.doorComboBox = TaurusAttrListComboBox(self) self.doorComboBox.setModel( self.macroServerComboBox.currentText() + "/doorList") self.buttonBox = Qt.QDialogButtonBox(Qt.QDialogButtonBox.Ok | Qt.QDialogButtonBox.Cancel) gridLayout = Qt.QGridLayout() gridLayout.addWidget(macroServerLabel, 0, 0) gridLayout.addWidget(self.macroServerComboBox, 0, 1) gridLayout.addWidget(refreshMacroServersButton, 0, 2) gridLayout.addWidget(doorLabel, 1, 0) gridLayout.addWidget(self.doorComboBox, 1, 1) self.setLayout(Qt.QVBoxLayout()) self.layout().addLayout(gridLayout) self.layout().addWidget(self.buttonBox) self.adjustSize() self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) self.macroServerComboBox.currentIndexChanged['QString'].connect( self.onMacroServerComboBoxChanged) self.selectMacroServer(self.initMacroServer) self.selectDoor(self.initDoor)
def initComponents(self): self.setModal(True) macroServerLabel = Qt.QLabel("MacroServer:", self) self.macroServerComboBox = Qt.QComboBox() ms_stateIcons = self.__retriveMacroServersFromDB() self.__fillMacroServerComboBox(ms_stateIcons, self.macroServerComboBox) refreshMacroServersButton = Qt.QToolButton() refreshMacroServersButton.setDefaultAction(self.refreshMacroServersAction) doorLabel = Qt.QLabel("Door:", self) self.doorComboBox = TaurusAttrListComboBox(self) self.doorComboBox.setModel(self.macroServerComboBox.currentText() + "/doorList") self.buttonBox = Qt.QDialogButtonBox(Qt.QDialogButtonBox.Ok | Qt.QDialogButtonBox.Cancel) gridLayout = Qt.QGridLayout() gridLayout.addWidget(macroServerLabel, 0, 0) gridLayout.addWidget(self.macroServerComboBox, 0, 1) gridLayout.addWidget(refreshMacroServersButton, 0, 2) gridLayout.addWidget(doorLabel, 1, 0) gridLayout.addWidget(self.doorComboBox, 1, 1) self.setLayout(Qt.QVBoxLayout()) self.layout().addLayout(gridLayout) self.layout().addWidget(self.buttonBox) self.adjustSize() self.connect(self.buttonBox, Qt.SIGNAL("accepted()"), self, Qt.SLOT("accept()")) self.connect(self.buttonBox, Qt.SIGNAL("rejected()"), self, Qt.SLOT("reject()")) self.connect(self.macroServerComboBox, Qt.SIGNAL("currentIndexChanged(const QString&)"), self.onMacroServerComboBoxChanged) self.selectMacroServer(self.initMacroServer) self.selectDoor(self.initDoor)
def __init__(self, parent=None, paramModel=None): TaurusAttrListComboBox.__init__(self, parent) ParamBase.__init__(self, paramModel) self.setModel("/" + self.paramModel().type() + "List")
class TaurusMacroConfigurationDialog(Qt.QDialog): def __init__(self, parent=None, initMacroServer=None, initDoor=None): Qt.QDialog.__init__(self, parent) self.initMacroServer = initMacroServer self.initDoor = initDoor configureAction = Qt.QAction(getThemeIcon("folder-open"), "Change custom macro editors paths", self) self.connect(configureAction, Qt.SIGNAL("triggered()"), self.onReloadMacroServers) configureAction.setToolTip("Change custom macro editors paths") configureAction.setShortcut("F11") self.refreshMacroServersAction = Qt.QAction(getThemeIcon("view-refresh"), "Reload macroservers", self) self.connect(self.refreshMacroServersAction, Qt.SIGNAL("triggered()"), self.onReloadMacroServers) self.refreshMacroServersAction.setToolTip("This will reload list of all macroservers from Tango DB") self.refreshMacroServersAction.setShortcut("F5") self.initComponents() def initComponents(self): self.setModal(True) macroServerLabel = Qt.QLabel("MacroServer:", self) self.macroServerComboBox = Qt.QComboBox() ms_stateIcons = self.__retriveMacroServersFromDB() self.__fillMacroServerComboBox(ms_stateIcons, self.macroServerComboBox) refreshMacroServersButton = Qt.QToolButton() refreshMacroServersButton.setDefaultAction(self.refreshMacroServersAction) doorLabel = Qt.QLabel("Door:", self) self.doorComboBox = TaurusAttrListComboBox(self) self.doorComboBox.setModel(self.macroServerComboBox.currentText() + "/doorList") self.buttonBox = Qt.QDialogButtonBox(Qt.QDialogButtonBox.Ok | Qt.QDialogButtonBox.Cancel) gridLayout = Qt.QGridLayout() gridLayout.addWidget(macroServerLabel, 0, 0) gridLayout.addWidget(self.macroServerComboBox, 0, 1) gridLayout.addWidget(refreshMacroServersButton, 0, 2) gridLayout.addWidget(doorLabel, 1, 0) gridLayout.addWidget(self.doorComboBox, 1, 1) self.setLayout(Qt.QVBoxLayout()) self.layout().addLayout(gridLayout) self.layout().addWidget(self.buttonBox) self.adjustSize() self.connect(self.buttonBox, Qt.SIGNAL("accepted()"), self, Qt.SLOT("accept()")) self.connect(self.buttonBox, Qt.SIGNAL("rejected()"), self, Qt.SLOT("reject()")) self.connect(self.macroServerComboBox, Qt.SIGNAL("currentIndexChanged(const QString&)"), self.onMacroServerComboBoxChanged) self.selectMacroServer(self.initMacroServer) self.selectDoor(self.initDoor) def accept(self): self.emit(Qt.SIGNAL("macroserverNameChanged"), str(self.macroServerComboBox.currentText())) self.emit(Qt.SIGNAL("doorNameChanged"), str(self.doorComboBox.currentText())) Qt.QDialog.accept(self) def __retriveMacroServersFromDB(self): ms_stateIcons = [] db = taurus.Database() macroServerList = db.getValueObj().get_device_name('*', 'MacroServer') for macroServer in macroServerList: #state = Device(macroServer).getState() state = None try: state = PyTango.DeviceProxy(macroServer).state() except: pass icon = None if state == PyTango.DevState.ON: icon = getIcon(":/leds/images24/ledgreen.png") elif state == PyTango.DevState.FAULT: icon = getIcon(":/leds/images24/ledred.png") elif state == None: icon = getIcon(":/leds/images24/ledredoff.png") ms_stateIcons.append((macroServer, icon)) return ms_stateIcons def onReloadMacroServers(self): ms_stateIcons = self.__retriveMacroServersFromDB() self.__fillMacroServerComboBox(ms_stateIcons, self.macroServerComboBox) def onMacroServerComboBoxChanged(self, macroServerName): self.doorComboBox.setModel(macroServerName + "/doorList") self.doorComboBox.fireEvent(self.doorComboBox, taurus.core.taurusbasetypes.TaurusEventType.Change, self.doorComboBox.getModelValueObj()) #fake event def onMacroServerNameChanged(self, macroServerName): self.__selectMacroServer(macroServerName) def onDoorNameChanged(self, doorName): self.__selectDoor(doorName) def __fillMacroServerComboBox(self, ms_stateIcons, comboBox): comboBox.clear() for ms_stateIcon in ms_stateIcons: macroServer = ms_stateIcon[0] icon = ms_stateIcon[1] comboBox.addItem(icon, macroServer) def selectDoor(self, doorName): if doorName is None: return #@todo: Change that it will be able to handle also full device names "/".join(doorName.split("/")[-3:]) index = self.doorComboBox.findText(doorName) if index != -1: self.doorComboBox.setCurrentIndex(index) def selectMacroServer(self, macroServerName): if macroServerName is None: return #@todo: Change that it will be able to handle also full device names "/".join(macroServerName.split("/")[-3:]) index = self.macroServerComboBox.findText(macroServerName) if index != -1: self.macroServerComboBox.setCurrentIndex(index)
class TaurusMacroConfigurationDialog(Qt.QDialog): def __init__(self, parent=None, initMacroServer=None, initDoor=None): Qt.QDialog.__init__(self, parent) self.initMacroServer = initMacroServer self.initDoor = initDoor configureAction = Qt.QAction(getThemeIcon("folder-open"), "Change custom macro editors paths", self) self.connect(configureAction, Qt.SIGNAL("triggered()"), self.onReloadMacroServers) configureAction.setToolTip("Change custom macro editors paths") configureAction.setShortcut("F11") self.refreshMacroServersAction = Qt.QAction( getThemeIcon("view-refresh"), "Reload macroservers", self) self.connect(self.refreshMacroServersAction, Qt.SIGNAL("triggered()"), self.onReloadMacroServers) self.refreshMacroServersAction.setToolTip( "This will reload list of all macroservers from Tango DB") self.refreshMacroServersAction.setShortcut("F5") self.initComponents() def initComponents(self): self.setModal(True) macroServerLabel = Qt.QLabel("MacroServer:", self) self.macroServerComboBox = Qt.QComboBox() ms_stateIcons = self.__retriveMacroServersFromDB() self.__fillMacroServerComboBox(ms_stateIcons, self.macroServerComboBox) refreshMacroServersButton = Qt.QToolButton() refreshMacroServersButton.setDefaultAction( self.refreshMacroServersAction) doorLabel = Qt.QLabel("Door:", self) self.doorComboBox = TaurusAttrListComboBox(self) self.doorComboBox.setModel(self.macroServerComboBox.currentText() + "/doorList") self.buttonBox = Qt.QDialogButtonBox(Qt.QDialogButtonBox.Ok | Qt.QDialogButtonBox.Cancel) gridLayout = Qt.QGridLayout() gridLayout.addWidget(macroServerLabel, 0, 0) gridLayout.addWidget(self.macroServerComboBox, 0, 1) gridLayout.addWidget(refreshMacroServersButton, 0, 2) gridLayout.addWidget(doorLabel, 1, 0) gridLayout.addWidget(self.doorComboBox, 1, 1) self.setLayout(Qt.QVBoxLayout()) self.layout().addLayout(gridLayout) self.layout().addWidget(self.buttonBox) self.adjustSize() self.connect(self.buttonBox, Qt.SIGNAL("accepted()"), self, Qt.SLOT("accept()")) self.connect(self.buttonBox, Qt.SIGNAL("rejected()"), self, Qt.SLOT("reject()")) self.connect(self.macroServerComboBox, Qt.SIGNAL("currentIndexChanged(const QString&)"), self.onMacroServerComboBoxChanged) self.selectMacroServer(self.initMacroServer) self.selectDoor(self.initDoor) def accept(self): self.emit(Qt.SIGNAL("macroserverNameChanged"), str(self.macroServerComboBox.currentText())) self.emit(Qt.SIGNAL("doorNameChanged"), str(self.doorComboBox.currentText())) Qt.QDialog.accept(self) def __retriveMacroServersFromDB(self): ms_stateIcons = [] db = taurus.Database() macroServerList = db.getValueObj().get_device_name('*', 'MacroServer') for macroServer in macroServerList: #state = Device(macroServer).getState() state = None try: state = PyTango.DeviceProxy(macroServer).state() except: pass icon = None if state == PyTango.DevState.ON: icon = getIcon(":/leds/images24/ledgreen.png") elif state == PyTango.DevState.FAULT: icon = getIcon(":/leds/images24/ledred.png") elif state == None: icon = getIcon(":/leds/images24/ledredoff.png") ms_stateIcons.append((macroServer, icon)) return ms_stateIcons def onReloadMacroServers(self): ms_stateIcons = self.__retriveMacroServersFromDB() self.__fillMacroServerComboBox(ms_stateIcons, self.macroServerComboBox) def onMacroServerComboBoxChanged(self, macroServerName): self.doorComboBox.setModel(macroServerName + "/doorList") self.doorComboBox.fireEvent( self.doorComboBox, taurus.core.taurusbasetypes.TaurusEventType.Change, self.doorComboBox.getModelValueObj()) #fake event def onMacroServerNameChanged(self, macroServerName): self.__selectMacroServer(macroServerName) def onDoorNameChanged(self, doorName): self.__selectDoor(doorName) def __fillMacroServerComboBox(self, ms_stateIcons, comboBox): comboBox.clear() for ms_stateIcon in ms_stateIcons: macroServer = ms_stateIcon[0] icon = ms_stateIcon[1] comboBox.addItem(icon, macroServer) def selectDoor(self, doorName): if doorName is None: return #@todo: Change that it will be able to handle also full device names "/".join(doorName.split("/")[-3:]) index = self.doorComboBox.findText(doorName) if index != -1: self.doorComboBox.setCurrentIndex(index) def selectMacroServer(self, macroServerName): if macroServerName is None: return #@todo: Change that it will be able to handle also full device names "/".join(macroServerName.split("/")[-3:]) index = self.macroServerComboBox.findText(macroServerName) if index != -1: self.macroServerComboBox.setCurrentIndex(index)
def __init__(self, parent=None, paramModel=None): ParamBase.__init__(self, paramModel) TaurusAttrListComboBox.__init__(self, parent) self.setModel("/" + self.paramModel().type() + "List")