def subscriberChanged(self): subPaths = self.subscriber.subPaths() if self.listWidget: self.listWidget.clear() elif self.tableWidget: self.tableWidget.clearContents() self.tableWidget.setRowCount(len(subPaths)) for i in xrange(len(subPaths)): v = self.subscriber.value(subPaths[i]) if self.listWidget: item = QListWidgetItem('%s (%s)\n%s' % (subPaths[i], str(type(v)), str(v))) item.setFlags(item.flags() & ~Qt.ItemIsEditable) self.listWidget.addItem(item) elif self.tableWidget: pathItem = QTableWidgetItem(subPaths[i]) pathItem.setFlags(pathItem.flags() & ~Qt.ItemIsEditable) valueItem = QTableWidgetItem(str(v)) valueItem.setFlags(pathItem.flags() & ~Qt.ItemIsEditable) typeItem = QTableWidgetItem(str(type(v))) typeItem.setFlags(pathItem.flags() & ~Qt.ItemIsEditable) self.tableWidget.setItem(i, 0, pathItem) self.tableWidget.setItem(i, 1, valueItem) self.tableWidget.setItem(i, 2, typeItem)
def set_controls(self, updated_files): for to_update in updated_files: item = QListWidgetItem('[%s] %s' % to_update) item.setFlags(item.flags() | Qt.ItemIsUserCheckable) #if to_update[0] == "U": # item.setCheckState(Qt.Unchecked) #else: item.setCheckState(Qt.Checked) self.ui.listFiles.addItem(item)