def open_dialog(self):
""" Open 'Open Dialog Box' """
if self.has_changed:
self.save_box(open=True)
try:
self.file_path = QtWidgets.QFileDialog.getOpenFileName(self, 'Open File', './',
filter="All Files(*.*);;Text Files(*.txt)")
if self.file_path[0]:
self.file_name = (self.file_path[0].split('/'))[-1]
self.setWindowTitle("{} - Notepad".format(self.file_name))
file_open = open(self.file_path[0], 'r+')
self.statusBar().showMessage('Open... {}'.format(self.file_path[0]))
with file_open:
content = file_open.read()
self.text_widget.setPlainText(content)
self.need_saving(False)
except UnicodeDecodeError as why:
self.error_box(why)
pass
评论列表
文章目录