simpletexteditor.py 文件源码

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

项目:PyGObject-examples 作者: VatsalP 项目源码 文件源码
def file_open(self, button):
        if self.filechanged:
            self.notsavetwo.set_transient_for(self.window)
            self.response = self.notsavetwo.run()

            if self.response == Gtk.ResponseType.YES:
                self.save(self.filesave)

            self.notsavetwo.hide()


        self.fileopen.set_transient_for(self.window)
        self.response = self.fileopen.run()

        if self.response == Gtk.ResponseType.OK:
            self.file_to_open = self.fileopen.get_filename()
            if self.file_to_open:
                self.currentfile = self.file_to_open
                self.path = pathlib.PurePath(self.currentfile)
                self.window.set_title(self.path.parts[-1])
                if self.path.parts:
                    self.window.set_title(self.path.parts[-1])
                else:
                    self.window.set_title("Untitled document")
                with codecs.open(self.file_to_open,
                                 'r',
                                 encoding="utf-8") as f:
                    self.content_file = f.read()
                    self.textbuffer.set_text(self.content_file)

        self.fileopen.hide()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号