This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Grammer_checkUI.py
114 lines (92 loc) · 3.74 KB
/
Grammer_checkUI.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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
from PyQt5.QtCore import QObject, QThread, pyqtSignal, QPoint
from PyQt5 import QtWidgets, uic
import sys
from Backend.grammarcheck import gcheck
from loading import Loading
from PyQt5 import QtCore
import time
class Mistakes(QtWidgets.QMainWindow):
def __init__(self,main):
self.main = main
super(Mistakes, self).__init__()
self.initUI()
#self.show()
def initUI(self):
uic.loadUi('./UI/Mistakes.ui', self)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.StartGrammerCheck()
self.Close = self.findChild(QtWidgets.QPushButton, 'Close')
self.minimize = self.findChild(QtWidgets.QPushButton, 'minimize')
self.Close.clicked.connect(self.Close_and_Open)
self.minimize.clicked.connect(self.showMinimized)
self.start = QPoint(0, 0)
self.pressing = False
# self.gmistake_textedit = self.findChild(QtWidgets.QPlainTextEdit, 'gmistake')
# self.gmistake_textedit.setReadOnly(True)
# self.essay_textedit = self.findChild(QtWidgets.QPlainTextEdit, 'essay')
# self.essay_textedit.setReadOnly(True)
# # f = open("backend/grammer_mistake.txt", "r")
# self.gmistake_textedit.insertPlainText(fg.read())
# # f.close()
# f = open("backend/essay.txt", "r")
# self.essay_textedit.insertPlainText(f.read())
def mousePressEvent(self, event):
self.start = self.mapToGlobal(event.pos())
self.pressing = True
def mouseMoveEvent(self, event):
if self.pressing:
self.end = self.mapToGlobal(event.pos())
self.movement = self.end-self.start
self.setGeometry(self.mapToGlobal(self.movement).x(),
self.mapToGlobal(self.movement).y(),
self.width(),
self.height())
self.start = self.end
def StartGrammerCheck(self):
# Step 2: Create a QThread object
self.thread = QThread()
# Step 3: Create a worker object
self.worker = Worker()
# Step 4: Move worker to the thread
self.worker.moveToThread(self.thread)
# Step 5: Connect signals and slots
self.thread.started.connect(self.worker.run)
self.worker.finished.connect(self.thread.quit)
self.worker.finished.connect(self.worker.deleteLater)
self.thread.finished.connect(self.thread.deleteLater)
# Step 6: Start the thread
self.window2=Loading()
self.window2.show()
self.main.close()
self.thread.start()
# # Final resets
# self.thread.finished.connect(
# fg = open("backend/grammer_mistake.txt", "r")
# )
self.thread.finished.connect(
lambda: self.After_thread()
)
self.thread.finished.connect(
# fe = open("backend/essay.txt", "r")
lambda: self.window2.close()
)
def After_thread(self):
self.gmistake_textedit = self.findChild(QtWidgets.QPlainTextEdit, 'gmistake')
self.gmistake_textedit.setReadOnly(True)
self.essay_textedit = self.findChild(QtWidgets.QPlainTextEdit, 'essay')
self.essay_textedit.setReadOnly(True)
fg = open("backend/grammer_mistake.txt", "r")
self.gmistake_textedit.insertPlainText(fg.read())
# f.close()
f = open("backend/essay.txt", "r")
self.essay_textedit.insertPlainText(f.read())
self.show()
def Close_and_Open(self):
self.main.show()
self.close()
class Worker(QObject):
finished = pyqtSignal()
def run(self):
grammer = gcheck()
grammer.Check_Grammer()
self.finished.emit()