def save_config_clicked(self, infile=True):
raw_config = self.configuration_textarea.toPlainText()
if raw_config == "":
print "Press Generate button first"
else:
try:
json_data = json.loads(raw_config)
self.core.configuration.Clear()
json2pb(self.core.configuration, json_data)
if infile:
json_data = pb2json(self.core.configuration)
filename = QtWidgets.QFileDialog.getSaveFileName()[0]
filepath = Path(filename)
if filepath != '':
bytes = json.dumps(json_data, indent=4)
filepath.write_bytes(bytes)
else:
print "Invalid file given %s" % str(filepath)
except KeyError as e:
print "invalid key:"+e.message
评论列表
文章目录