Точное сохранение и открытие кода выглядит так:
Код: Выделить всё
def savefile(self):
try:
self.save_file_url = QFileDialog.getSaveFileName(self,"Save File", "", "Text Files(*.txt)")
if self.save_file_url:
with open(self.save_file_url[0], "a") as f:
f.write(self.textarea.toPlainText())
except:
QMessageBox.about(self, "Error 001", "Something went wrong...")
def openfile(self):
try:
openfilename = QFileDialog.getOpenFileName()
with open(openfilename[0], "r") as file:
self.textarea.setPlainText(file.readline())
except:
QMessageBox.about(self, "Error 002", "Something went wrong...")
def colorshortcut(self):
return self.colorDialog()
Подробнее здесь: https://stackoverflow.com/questions/793 ... thon-pyqt5
Мобильная версия