def save_dialog(self):
try:
save_dialog = QtWidgets.QFileDialog()
save_dialog.setAcceptMode(QtWidgets.QFileDialog.AcceptSave)
file_path = save_dialog.getSaveFileName(self, 'Save as... File', './',
filter='All Files(*.*);; Text Files(*.txt)')
if file_path[0]:
self.file_path = file_path
file_open = open(self.file_path[0], 'w')
self.file_name = (self.file_path[0].split('/'))[-1]
self.statusBar().showMessage('Saved at: {}'.format(self.file_path[0]))
self.setWindowTitle("{} - Notepad".format(self.file_name))
with file_open:
file_open.write(self.text_widget.toPlainText())
self.need_saving(False)
except FileNotFoundError as why:
self.error_box(why)
pass
评论列表
文章目录