class attributeChooser(TaurusAttributeChooser): def __init__(self): TaurusAttributeChooser.__init__(self, parent=None, designMode=False) self.tdb = PyTangoArchiving.Reader('tdb') self.beingArchived = [] self.beingArchived = [ a.lower() for a in self.tdb.get_attributes() if self.tdb.is_attribute_archived(a.lower()) ] #already archived attributes self.connect(self.ui.lineEdit, Qt.SIGNAL("textChanged (const QString&)"), self.setNewDevName) self.setNewDevName() def setAttributes(self): """Fill the attributes list""" import PyTango self.ui.attrList.clear() self.dev_name = str(self.ui.devList.currentItem().text()) try: items = [ str(a.name) for a in PyTango.DeviceProxy( self.dev_name).attribute_list_query() ] except Exception, e: self.warning('Unable to contact with device %s: %s' % (self.dev_name, str(e))) items = [] items.sort( key=lambda x: x.lower()) #sort the attributes (case insensitive!) for i in range(len(items)): fullname = str(self.dev_name + '/' + items[i]).lower() item = Qt.QListWidgetItem() item.setText(str(items[i])) if fullname in self.beingArchived: item.setIcon(getThemeIcon("appointment-new")) self.ui.attrList.addItem(item)
self.ui.attrList.addItem(item) def setNewDevName(self): """Fill the devices list""" device = str(self.ui.lineEdit.text()) device += '*' try: items = list(self.getDb().get_device_exported(device)) except Exception, e: self.warning('Unable to contact with device %s: %s' % (device, str(e))) items = [] self.ui.devList.clear() devs = set([d.rsplit('/', 1)[0].lower() for d in self.beingArchived]) for i in items: item = Qt.QListWidgetItem() item.setText(str(i)) if str(i).lower() in devs: item.setIcon(getThemeIcon("appointment-new")) self.ui.devList.addItem(item) self.connect(self.ui.devList, Qt.SIGNAL("itemSelectionChanged ()"), self.setAttributes) class historyButton(Qt.QPushButton): def __init__(self): Qt.QPushButton.__init__(self) self.setMaximumWidth(40) self.setIcon(getThemeIcon("appointment-new")) self.setToolTip('show history') self.connect(self, Qt.SIGNAL("clicked()"), self.onButtonClicked)