notepad.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:notepad 作者: lfsando 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号