- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrontend.py
More file actions
Latest commit
75 lines (57 loc) · 2.51 KB
/
Copy pathFrontend.py
File metadata and controls
75 lines (57 loc) · 2.51 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
importsys
importos
fromPyQt5.QtWidgetsimportQApplication, QWidget, QMainWindow, QButtonGroup
fromPILimportImageQt
fromUser_interfaceimportUi_MainWindow
fromCoreimportmain
classMyWidget(QMainWindow,Ui_MainWindow):
def__init__(self):
super().__init__()
self.setupUi(self)
self.correction_level=1
self.encoding_type='UTF8'
self.image=None
self.button_group=QButtonGroup()
self.button_group.addButton(self.digit_button)
self.button_group.addButton(self.alphadigit_button)
self.button_group.addButton(self.UTF8_button)
self.GenerateButton.clicked.connect(self.generate)
self.SaveButton.clicked.connect(self.save)
self.CorrectionSlider.valueChanged.connect(self.change_level)
self.button_group.buttonClicked.connect(self.encode_choice)
defgenerate(self):
data=self.DataEdit.toPlainText()
response, self.image=main(data, self.encoding_type, self.correction_level)
ifresponse==0:
self.ErrorLine.setText('Ïðèñóòñòâóþò íåäîïóñòèìûå ñèìâîëû')
elifresponse==1:
self.ErrorLine.setText('Íåäîïóñòèìûé îáú¸ì äàííûõ')
else:
self.ErrorLine.setText('Êîä ñãåíåðèðîâàí óñïåøíî')
self.PictureLabel.setPixmap(ImageQt.toqpixmap(self.image))
defsave(self):
ifself.image==None:
self.ErrorLine.setText('Îòñóòñòâóåò êîä äëÿ ñîõðàíåíèÿ')
else:
path=self.PathLine.text()
try:
ifos.path.exists(path):
os.remove(path)
self.image.save(path)
exceptException:
self.ErrorLine.setText('Ïðîâåðüòå ïðàâèëüíîñòü óêàçàííîãî ïóòè')
else:
self.ErrorLine.setText('Óñïåøíî ñîõðàíåíî')
defchange_level(self, number):
self.correction_level=number
defencode_choice(self, button):
ifbutton==self.digit_button:
self.encoding_type='digit'
elifbutton==self.alphadigit_button:
self.encoding_type='alphadigit'
else:
self.encoding_type='UTF8'
app=QApplication(sys.argv)
ex=MyWidget()
ex.show()
sys.exit(app.exec_())