def setResRelPath(self): rows = set() for item in self.fileTable.selectedItems(): rows.add(item.row()) # Can't set relative path of the config or sim files so warn # if selected and drop the indexes for those rows if 0 in rows: QMessageBox.information( self, "Warning", "Won't set releative path for configuration") if 1 in rows: QMessageBox.information(self, "Warning", "Won't set releative path for model") rows.discard(0) rows.discard(1) if len(rows) == 0: return relpath, ok = QInputDialog.getText( self, "Relative path", "Enter a relative path for selected resources:", QLineEdit.Normal) if ok: relpath = relpath.strip() relpath = relpath.strip('\\/') for row in rows: gh.setCellText(self.fileTable, row, 0, '\\'.join([relpath, self.files[row][0]]))
def _load(self, file="test.json"): try: with open(file, "r") as fp: d = json.load(fp) except: _log.exception("Couldn't load file {}".format(file)) return # Currently doesn't load these because you can't change them # filetype, filetype-version, and SignatureMethodAlgorithm index = self.application_name.findText(d["application"].get( "name", "")) if index >= 0: self.application_name.setCurrentIndex(index) self.application_version.setText(d["application"].get("version", "")) self.title.setText(d.get("title", "")) self.author.setText(d.get("author", "")) self.date.setText(d.get("date", "")) self.description.setText(d.get("description", "")) self.config_version.setText(d.get("config-version", "1.0")) if "model" in d: self.model_file.setText(d["model"].get("file", "")) self.model_digest_value.setText(d["model"].get("DigestValue", "")) tbl = self.settings_table for row in range(tbl.rowCount()): if not "settings" in d: break sname = tbl.verticalHeaderItem(row).text() if sname in d["settings"]: gh.setCellText(tbl, row, 0, d["settings"][sname]["type"]) gh.setCellText(tbl, row, 1, d["settings"][sname]["default"]) gh.setCellText(tbl, row, 2, d["settings"][sname]["description"]) files = d.get("input-files", []) tbl = self.input_files_table tbl.setRowCount(0) for row, file in enumerate(files): self._add_blank_input_file() gh.setCellText(tbl, row, 0, file["file"]) gh.setCellText(tbl, row, 1, file["DigestValue"]) gh.cellPulldownSetText(tbl, row, 2, file["SignatureMethodAlgorithm"]) tbl = self.inputs_table tbl.setRowCount(0) for x, xd in d.get("inputs", {}).items(): row = tbl.rowCount() self._add_input() gh.setCellText(tbl, row, 0, x) gh.setCellText(tbl, row, 1, xd.get("path", [""])[0]) gh.cellPulldownSetText(tbl, row, 2, xd.get("type", "double")) gh.setCellText(tbl, row, 3, xd.get("default", "")) gh.setCellText(tbl, row, 4, xd.get("max", "")) gh.setCellText(tbl, row, 5, xd.get("min", "")) units = xd.get("units", "") if units is None: units = "" gh.setCellText(tbl, row, 6, units) gh.setCellText(tbl, row, 7, xd.get("description", "")) tbl = self.outputs_table tbl.setRowCount(0) for x, xd in d.get("outputs", {}).items(): row = tbl.rowCount() self._add_output() gh.setCellText(tbl, row, 0, x) gh.setCellText(tbl, row, 1, xd.get("path", [""])[0]) gh.cellPulldownSetText(tbl, row, 2, xd.get("type", "double")) gh.setCellText(tbl, row, 3, xd.get("default", "")) units = xd.get("units", "") if units is None: units = "" gh.setCellText(tbl, row, 4, units) gh.setCellText(tbl, row, 5, xd.get("description", ""))