-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.py
32 lines (24 loc) · 786 Bytes
/
code.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import des
import codecs
import sys
from PyQt5 import QtWidgets
class ExampleApp(QtWidgets.QMainWindow, des.Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
self.actionNew.triggered.connect(self.New)
self.actionSave.triggered.connect(self.Save)
def New(self):
self.textEdit.setText('')
def Save(self):
file = QtWidgets.QFileDialog.getSaveFileName(self, 'Сохранить', 'D:/', filter=('.txt'))[0]
with codecs.open(file + '.txt', 'w', encoding='utf8') as f:
f.write(self.textEdit.toPlainText())
f.close()
def main():
app = QtWidgets.QApplication(sys.argv)
window = ExampleApp()
window.show()
app.exec_()
if __name__ == '__main__':
main()