-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.py
224 lines (207 loc) · 9.11 KB
/
gui.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
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'dbmsproject.ui'
#
# Created by: PyQt5 UI code generator 5.15.6
#
# 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 QtCore, QtGui, QtWidgets
import keys_identification
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(965, 613)
MainWindow.setAutoFillBackground(False)
MainWindow.setStyleSheet("\n"
"background-color: #1b242b;")
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.txtRelation = QtWidgets.QLineEdit(self.centralwidget)
self.txtRelation.setGeometry(QtCore.QRect(30, 50, 211, 41))
font = QtGui.QFont()
font.setPointSize(11)
font.setKerning(True)
self.txtRelation.setFont(font)
self.txtRelation.setStyleSheet("background-color: #334754;\n"
"color: rgb(255, 255, 255);")
self.txtRelation.setFrame(False)
self.txtRelation.setObjectName("txtRelation")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(30, 25, 221, 21))
font = QtGui.QFont()
font.setFamily("Product Sans")
font.setPointSize(12)
font.setBold(False)
font.setWeight(50)
self.label.setFont(font)
self.label.setStyleSheet("color: rgb(255, 255, 255);")
self.label.setObjectName("label")
self.txtFDLeft = QtWidgets.QLineEdit(self.centralwidget)
self.txtFDLeft.setGeometry(QtCore.QRect(30, 150, 161, 41))
font = QtGui.QFont()
font.setPointSize(11)
font.setKerning(True)
self.txtFDLeft.setFont(font)
self.txtFDLeft.setStyleSheet("background-color: #334754;\n"
"color: rgb(255, 255, 255);")
self.txtFDLeft.setFrame(False)
self.txtFDLeft.setObjectName("txtFDLeft")
self.txtFDRight = QtWidgets.QLineEdit(self.centralwidget)
self.txtFDRight.setGeometry(QtCore.QRect(240, 150, 161, 41))
font = QtGui.QFont()
font.setPointSize(11)
font.setKerning(True)
self.txtFDRight.setFont(font)
self.txtFDRight.setStyleSheet("background-color: #334754;\n"
"color: rgb(255, 255, 255);")
self.txtFDRight.setFrame(False)
self.txtFDRight.setObjectName("txtFDRight")
self.label_3 = QtWidgets.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(30, 120, 331, 21))
font = QtGui.QFont()
font.setFamily("Product Sans")
font.setPointSize(12)
font.setBold(False)
font.setWeight(50)
self.label_3.setFont(font)
self.label_3.setStyleSheet("color: rgb(255, 255, 255);")
self.label_3.setObjectName("label_3")
self.btnAdd = QtWidgets.QPushButton(self.centralwidget)
self.btnAdd.setGeometry(QtCore.QRect(30, 200, 91, 31))
font = QtGui.QFont()
font.setFamily("Product Sans")
font.setPointSize(12)
font.setBold(False)
font.setWeight(50)
self.btnAdd.setFont(font)
self.btnAdd.setStyleSheet("background-color: #425a64;\n"
"color: rgb(255, 255, 255);")
self.btnAdd.setObjectName("btnAdd")
self.btnAdd.clicked.connect(self.addFD)
self.btnSubmit = QtWidgets.QPushButton(self.centralwidget)
self.btnSubmit.setGeometry(QtCore.QRect(30, 530, 371, 41))
font = QtGui.QFont()
font.setFamily("Product Sans")
font.setPointSize(12)
font.setBold(False)
font.setWeight(50)
self.btnSubmit.setFont(font)
self.btnSubmit.setStyleSheet("background-color: #425a64;\n"
"color: rgb(255, 255, 255);")
self.btnSubmit.setObjectName("btnSubmit")
self.btnSubmit.clicked.connect(self.onSubmit)
self.line = QtWidgets.QFrame(self.centralwidget)
self.line.setGeometry(QtCore.QRect(470, -10, 20, 631))
self.line.setAutoFillBackground(False)
self.line.setFrameShadow(QtWidgets.QFrame.Plain)
self.line.setLineWidth(0)
self.line.setFrameShape(QtWidgets.QFrame.VLine)
self.line.setObjectName("line")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(560, 120, 181, 21))
font = QtGui.QFont()
font.setFamily("Product Sans")
font.setPointSize(12)
font.setBold(False)
font.setWeight(50)
self.label_2.setFont(font)
self.label_2.setStyleSheet("color: rgb(255, 255, 255);")
self.label_2.setObjectName("label_2")
self.label_4 = QtWidgets.QLabel(self.centralwidget)
self.label_4.setGeometry(QtCore.QRect(190, 150, 41, 41))
self.label_4.setStyleSheet("")
self.label_4.setText("")
self.label_4.setPixmap(QtGui.QPixmap("D:/Innovative Assigments/DBMS Project/arrow.png"))
self.label_4.setScaledContents(True)
self.label_4.setObjectName("label_4")
self.keysList = QtWidgets.QListWidget(self.centralwidget)
self.keysList.setGeometry(QtCore.QRect(560, 150, 321, 371))
font = QtGui.QFont()
font.setPointSize(11)
self.keysList.setFont(font)
self.keysList.setStyleSheet("color: rgb(255, 255, 255);")
self.keysList.setObjectName("keysList")
self.fdList = QtWidgets.QListWidget(self.centralwidget)
self.fdList.setGeometry(QtCore.QRect(30, 260, 371, 192))
font = QtGui.QFont()
font.setPointSize(11)
self.fdList.setFont(font)
self.fdList.setStyleSheet("color: rgb(255, 255, 255);")
self.fdList.setObjectName("fdList")
self.btnDelete = QtWidgets.QPushButton(self.centralwidget)
self.btnDelete.setGeometry(QtCore.QRect(30, 460, 91, 31))
font = QtGui.QFont()
font.setFamily("Product Sans")
font.setPointSize(12)
font.setBold(False)
font.setWeight(50)
self.btnDelete.setFont(font)
self.btnDelete.setStyleSheet("background-color: #425a64;\n"
"color: rgb(255, 255, 255);")
self.btnDelete.setObjectName("btnDelete")
self.btnDelete.clicked.connect(self.delete)
self.btnClear = QtWidgets.QPushButton(self.centralwidget)
self.btnClear.setGeometry(QtCore.QRect(140, 460, 91, 31))
font = QtGui.QFont()
font.setFamily("Product Sans")
font.setPointSize(12)
font.setBold(False)
font.setWeight(50)
self.btnClear.setFont(font)
self.btnClear.setStyleSheet("background-color: #425a64;\n"
"color: rgb(255, 255, 255);")
self.btnClear.setObjectName("btnClear")
self.btnClear.clicked.connect(self.clearAll)
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Keys Identification"))
self.label.setText(_translate("MainWindow", "Enter Relation:"))
self.label_3.setText(_translate("MainWindow", "Enter Functional Dependency:"))
self.btnAdd.setText(_translate("MainWindow", "Add"))
self.btnSubmit.setText(_translate("MainWindow", "Find Keys"))
self.label_2.setText(_translate("MainWindow", "Candidate Keys:"))
self.btnDelete.setText(_translate("MainWindow", "Delete"))
self.btnClear.setText(_translate("MainWindow", "Clear All"))
def addFD(self):
self.fdList.addItem(self.txtFDLeft.text() + "->" + self.txtFDRight.text())
self.txtFDLeft.clear()
self.txtFDRight.clear()
def delete(self):
selected = self.fdList.currentItem()
if not selected: return
selected = self.fdList.currentRow()
self.fdList.takeItem(selected)
self.fdList.repaint()
def clearAll(self):
self.fdList.clear()
self.keysList.clear()
self.txtRelation.clear()
self.txtFDLeft.clear()
self.txtFDRight.clear()
def onSubmit(self):
self.keysList.clear()
fd_list = []
for index in range(self.fdList.count()):
fd_list.append(self.fdList.item(index).text())
# print(items)
relation=self.txtRelation.text()
keys = []
keys = keys_identification.submit(relation, fd_list)
print("keys: ", keys)
for x in keys:
item = ','.join(map(str, x))
self.keysList.addItem(item)
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_())