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()
评论列表
文章目录