def addVar(name, source, selected=False): row = addVar.ind % maxrows col = int(addVar.ind / maxrows) item = QTableWidgetItem(name) item.source = source table.setItem(row, col, item) item.setSelected(selected) addVar.ind += 1
def addVar(name, source, selected=False): var = source.variables[name] item = QTableWidgetItem(name) item.source = source table.setItem(addVar.ind, 0, item) item.setSelected(selected) comment = var.desc if comment == "": comment = var.label if var.units != "": comment += " ("+var.units+") " if var.dim: try: comment += " [" + ", ".join([str(v) for v in var.dim]) + "]" except TypeError: if str(var.dim): comment += " [" + str(var.dim) + "]" item = QTableWidgetItem(comment) table.setItem(addVar.ind, 1, item) item.setSelected(selected) addVar.ind += 1
def addVar(name, source, selected=False): var = source.variables[name] item = QTableWidgetItem(name) item.source = source table.setItem(addVar.ind, 0, item) item.setSelected(selected) comment = var.desc if comment == "": comment = var.label if var.units != "": comment += " (" + var.units + ") " if var.dim: try: dim_string = "[" + ", ".join([str(v) for v in var.dim]) + "]" except TypeError: dim_string = f"[{str(var.dim)}]" if dim_string != "[]": comment += f" {dim_string}" item = QTableWidgetItem(comment) table.setItem(addVar.ind, 1, item) item.setSelected(selected) addVar.ind += 1