def saveProject(self):
"""
Save all variables to file
"""
prj_filename = self.showSaveDialog(self.tr('Save project to file'), "Project files (*%s)" % c.PROJECT_EXTENSION)
save_prj_filename = file_str(prj_filename[0])
# If Cancel was pressed
if not save_prj_filename:
return
(beg, ende) = os.path.split(save_prj_filename)
(fileBaseName, fileExtension) = os.path.splitext(ende)
if fileExtension != c.PROJECT_EXTENSION:
if not QtCore.QFile.exists(save_prj_filename):
save_prj_filename += c.PROJECT_EXTENSION
pyCode = self.d2g.export()
try:
# File open and write
f = open(save_prj_filename, "w")
f.write(str_encode(pyCode))
f.close()
logger.info(self.tr("Save project to FILE was successful"))
except IOError:
QMessageBox.warning(g.window,
self.tr("Warning during Save Project As"),
self.tr("Cannot Save the File"))
评论列表
文章目录