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
/
MainUI.py
273 lines (227 loc) · 9.62 KB
/
MainUI.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
from PyQt5 import QtWidgets, uic
import sys
from PyQt5 import QtCore
from PyQt5.QtCore import QPoint
from DetailsUI import DetailsUI
from Grammer_checkUI import Mistakes
from Scores import ScoreUI
import pandas as pd
import webbrowser
class MainUI(QtWidgets.QMainWindow):
def __init__(self):
super(MainUI, self).__init__()
self.initUI()
def initUI(self):
uic.loadUi('./UI/MainUI.ui', self)
#Hide title bar
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
#Push buttons
self.essay_details = self.findChild(QtWidgets.QPushButton, 'essay_details')
self.grammer_check = self.findChild(QtWidgets.QPushButton, 'grammer_check')
self.essay_score = self.findChild(QtWidgets.QPushButton, 'essay_score')
self.essay_report = self.findChild(QtWidgets.QPushButton, 'essay_report')
self.Save_essay = self.findChild(QtWidgets.QPushButton, 'Save_essay')
self.Close = self.findChild(QtWidgets.QPushButton, 'Close')
self.minimize = self.findChild(QtWidgets.QPushButton, 'minimize')
#button connect
self.essay_details.clicked.connect(self.Disp_essay_details)
self.grammer_check.clicked.connect(self.Disp_grammer_check)
self.essay_score.clicked.connect(self.Disp_essay_score)
self.essay_report.clicked.connect(self.Disp_essay_report)
self.Save_essay.clicked.connect(self.Disp_Save_essay)
self.Close.clicked.connect(sys.exit)
self.minimize.clicked.connect(self.showMinimized)
#move window to (50,5)
self.move(50, 5)
#self.show()
self.start = QPoint(0, 0)
self.pressing = False
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 Disp_essay_details(self):
self.window=DetailsUI(self)
def Disp_grammer_check(self):
self.window=Mistakes(self)
def Disp_Save_essay(self):
Essay = self.plainTextEdit.toPlainText()
df = pd.read_csv("Backend/essay.csv")
df.loc[0,"Essay"] = Essay
df.to_csv("Backend/essay.csv",index=False)
with open('./Backend/essay.txt', 'w') as f:
f.write(Essay)
def Disp_essay_score(self):
self.window = ScoreUI(self)
def Disp_essay_report(self):
content = '''
<html>
<head>
<link rel="stylesheet" href="report.css">
</head>
<body>
Essay:<br>{essay}<br>
<br><br>
Number of Character: {NumberofChar}<br>
No. of words: {No_of_words} <br>
No. of unique: {No_of_unique}<br>
Noun: {Noun}<br>
Adjectives: {Adjectives}<br>
Verb: {Verb}<br>
Adverb: {Adverb}<br>
Grammer Mistakes: {GrammerMistakes}<br>
Score: {Score}<br>
</body>
</html>
'''
df = pd.read_csv("Backend/essay.csv")
essay = df.loc[0,"Essay"]
NumberofChar = df.loc[0,"Number of Char"]
No_of_words = df.loc[0,"No. of words"]
No_of_unique = df.loc[0,"No. of unique"]
Noun = df.loc[0,"Noun"]
Adjectives = df.loc[0,"Adjectives"]
Verb = df.loc[0,"Verb"]
Adverb = df.loc[0,"Adverb"]
GrammerMistakes = df.loc[0,"Grammer Mistakes"]
Score = df.loc[0,"Score"]
htmlcontent = content.format(**locals())
outfile = open('test.html','w')
outfile.write(htmlcontent)
outfile.close()
webbrowser.open("test.html")
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
window = MainUI()
window.show()
app.exec_()
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'projectone.ui'
#
# Created by: PyQt5 UI code generator 5.15.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
# from PyQt5 import QtWidgets, uic
# from PyQt5 import QtCore, QtGui, QtWidgets
# from DetailsUI import DetailsUI
# from Grammer_checkUI import Mistakes
# from Plagarism_checkUI import Plagarism_c
# from EssayScoreUI import Score
# class Ui_MainWindow(object):
# def openwindow(self):
# self.window=DetailsUI()
# self.window.show()
# def openwindow2(self):
# self.window=Mistakes()
# self.window.show()
# def openwindow4(self):
# self.window=Score()
# self.window.show()
# def openwindow3(self):
# self.window=Plagarism_c()
# self.window.show()
# def setupUi(self, MainWindow):
# MainWindow.setObjectName("MainWindow")
# MainWindow.resize(771, 611)
# MainWindow.setAutoFillBackground(False)
# MainWindow.setStyleSheet("QWidget{\n"
# " background-color: rgb(131, 249, 255);\n"
# " \n"
# " \n"
# " background-color: qlineargradient(spread:repeat, x1:0, y1:0, x2:1, y2:0, stop:0.0681818 rgba(38, 209, 255, 255), stop:1 rgba(91, 43, 255, 255));\n"
# "}\n"
# "\n"
# "QPlainTextEdit{\n"
# " \n"
# " background-color: rgb(255, 255, 255);\n"
# "\n"
# "\n"
# "}")
# MainWindow.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
# self.centralwidget = QtWidgets.QWidget(MainWindow)
# self.centralwidget.setObjectName("centralwidget")
# self.label = QtWidgets.QLabel(self.centralwidget)
# self.label.setGeometry(QtCore.QRect(140, 0, 551, 41))
# font = QtGui.QFont()
# font.setPointSize(20)
# self.label.setFont(font)
# self.label.setObjectName("label")
# self.label_2 = QtWidgets.QLabel(self.centralwidget)
# self.label_2.setGeometry(QtCore.QRect(110, 60, 171, 51))
# font = QtGui.QFont()
# font.setPointSize(16)
# self.label_2.setFont(font)
# self.label_2.setObjectName("label_2")
# self.Button1 = QtWidgets.QPushButton(self.centralwidget)
# self.Button1.setGeometry(QtCore.QRect(620, 170, 111, 41))
# font = QtGui.QFont()
# font.setPointSize(10)
# self.Button1.setFont(font)
# self.Button1.setObjectName("Button1")
# self.Button1.clicked.connect(self.openwindow)
# self.Button_2 = QtWidgets.QPushButton(self.centralwidget)
# self.Button_2.setGeometry(QtCore.QRect(620, 230, 111, 41))
# font = QtGui.QFont()
# font.setPointSize(10)
# self.Button_2.setFont(font)
# self.Button_2.setObjectName("Button_2")
# self.Button_2.clicked.connect(self.openwindow2)
# self.Button_3 = QtWidgets.QPushButton(self.centralwidget)
# self.Button_3.setGeometry(QtCore.QRect(620, 290, 111, 41))
# font = QtGui.QFont()
# font.setPointSize(10)
# self.Button_3.setFont(font)
# self.Button_3.setObjectName("Button_3")
# self.Button_3.clicked.connect(self.openwindow3)
# self.Button_4 = QtWidgets.QPushButton(self.centralwidget)
# self.Button_4.setGeometry(QtCore.QRect(620, 350, 111, 41))
# self.Button_4.setObjectName("Button_4")
# self.Button_4.clicked.connect(self.openwindow4)
# self.button_SaveButton = QtWidgets.QPushButton(self.centralwidget)
# self.button_SaveButton.setGeometry(QtCore.QRect(300, 550, 111, 41))
# self.button_SaveButton.setObjectName("SaveButton")
# self.button_SaveButton.clicked.connect(self.SaveEssay)
# self.plainTextEdit = QtWidgets.QPlainTextEdit(self.centralwidget)
# self.plainTextEdit.setGeometry(QtCore.QRect(10, 150, 591, 391))
# self.plainTextEdit.setObjectName("plainTextEdit")
# MainWindow.setCentralWidget(self.centralwidget)
# self.statusbar = QtWidgets.QStatusBar(MainWindow)
# self.statusbar.setObjectName("statusbar")
# MainWindow.setStatusBar(self.statusbar)
# # self.button_SaveButton = self.centralwidget.findChild(QtWidgets.QPushButton,'SaveButton')
# # print(self.button_SaveButton)
# # self.button_SaveButton.clicked.connect(self.SaveEssay)
# self.retranslateUi(MainWindow)
# QtCore.QMetaObject.connectSlotsByName(MainWindow)
# def SaveEssay(self):
# Essay = self.plainTextEdit.toPlainText()
# with open('./Backend/essay.txt', 'w') as f:
# f.write(Essay)
# def retranslateUi(self, MainWindow):
# _translate = QtCore.QCoreApplication.translate
# MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
# self.label.setText(_translate("MainWindow", "Automatic Essay Scorer and Recommendation"))
# self.label_2.setText(_translate("MainWindow", "Enter Your Essay"))
# self.Button1.setText(_translate("MainWindow", "get essay details"))
# self.Button_2.setText(_translate("MainWindow", "grammer check"))
# self.Button_3.setText(_translate("MainWindow", "plagarism check"))
# self.Button_4.setText(_translate("MainWindow", "Get essay score"))
# self.button_SaveButton.setText(_translate("MainWindow", "Save Essay"))
# self.plainTextEdit.setPlainText(_translate("MainWindow", "enter your essay...\n"""))
# if __name__ == "__main__":
# import sys
# app = QtWidgets.QApplication(sys.argv)
# MainWindow = QtWidgets.QMainWindow()
# ui = Ui_MainWindow()
# ui.setupUi(MainWindow)
# MainWindow.show()
# sys.exit(app.exec_())