-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
49 lines (38 loc) · 1.33 KB
/
main.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import sys
import threading
from PyQt5 import uic, QtCore
from PyQt5.QtWidgets import QMainWindow, QApplication, QFileDialog
from PyQt5.QtCore import QSize, pyqtSignal
import requester
import scanner
class Client(QMainWindow):
show_request = pyqtSignal(str)
def __init__(self):
super().__init__()
self.init_ui()
def init_ui(self):
uic.loadUi("main_window.ui", self)
self.show_request.connect(self.show_string)
self.submit.clicked.connect(self.react)
def react(self):
def convert():
try:
self.sentence_quantity = self.output_size_sent.text()
print(self.sentence_quantity)
self.file_name = QFileDialog.getOpenFileName(self, 'Выбрать картинку', '')[0]
if self.file_name == "":
return
output = scanner.scan(self.file_name)
output = requester.request(output, self.sentence_quantity)
self.show_request.emit(output)
except Exception as e:
print(e)
threading.Thread(target=convert).start()
def show_string(self, s):
print(s)
self.output_window.setText(s)
if __name__ == "__main__":
app = QApplication(sys.argv)
client = Client()
client.show()
sys.exit(app.exec())