-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathresults.py
More file actions
89 lines (71 loc) · 2.81 KB
/
results.py
File metadata and controls
89 lines (71 loc) · 2.81 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'results.ui'
#
# Created: Fri Apr 1 11:53:10 2016
# by: PyQt4 UI code generator 4.10.4
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
import sqlite3
import sys
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Results(object):
def setupUi(self, Results, query):
Results.setObjectName(_fromUtf8("Results"))
Results.setWindowModality(QtCore.Qt.ApplicationModal)
Results.resize(400, 300)
Results.setModal(True)
self.verticalLayout = QtGui.QVBoxLayout(Results)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.tableWidget = QtGui.QTableWidget(Results)
self.tableWidget.setObjectName(_fromUtf8("tableWidget"))
self.tableWidget.setSortingEnabled(True)
query += ';'
print(query)
conn = sqlite3.connect('be_proj_check.db')
cursor = conn.cursor()
cursor.execute(query)
results = cursor.fetchall()
print (results)
print(cursor.description)
label = list()
for item in cursor.description:
label.append(item[0])
print (label)
self.tableWidget.setColumnCount(len(label))
self.tableWidget.setRowCount(len(results))
self.tableWidget.setHorizontalHeaderLabels(label)
for i in range(len(results)):
for j in range(len(label)):
self.tableWidget.setItem(i, j, QtGui.QTableWidgetItem(str(results[i][j])))
self.verticalLayout.addWidget(self.tableWidget)
self.buttonBox = QtGui.QDialogButtonBox(Results)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
self.verticalLayout.addWidget(self.buttonBox)
self.retranslateUi(Results)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), Results.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Results.reject)
QtCore.QMetaObject.connectSlotsByName(Results)
Results.show()
def retranslateUi(self, Results):
Results.setWindowTitle(_translate("Results", "Dialog", None))
'''
app = QtGui.QApplication([])
win = QtGui.QDialog()
foo = Ui_Results()
foo.setupUi(win)
sys.exit(app.exec_())
'''