-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathList.py
81 lines (65 loc) · 2.74 KB
/
List.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
from PyQt5 import QtWidgets, uic
from PyQt5.QtWidgets import QMessageBox, QDialog
from PyQt5 import QtCore
from PyQt5.QtGui import QStandardItemModel, QStandardItem
import sys
from PyQt5.uic import loadUiType
# import interface.Dataset as ds
import Database as DS
# conn = ds.connect_database()
Con = DS.connect_database()
class AddContact(QtWidgets.QDialog):
def __init__(self, model):
super(AddContact, self).__init__()
self.w = uic.loadUi('add.ui', self)
print('add.ui')
self.model = model
self.w.show()
self.w.buttonBox.accepted.connect(self.addContact)
def addContact(self):
print('add')
firstname = self.w.lineEditFirstName.text()
lastname = self.w.lineEditLastName.text()
email = self.w.lineEditEmail.text()
row = (QStandardItem(firstname), QStandardItem(lastname), QStandardItem(email))
self.model.appendRow(row)
class Example(QtWidgets.QMainWindow):
def __init__(self):
super(Example, self).__init__()
uic.loadUi('UI/List_window.ui', self)
self.model1 = QStandardItemModel()
self.model1.setHorizontalHeaderLabels(['Id', 'Serial Number', 'Length', 'Width', 'Height', 'Quantity'])
self.tableView2.setModel(self.model1)
self.tableView2.horizontalHeader().setSectionResizeMode(1)
self.model = QStandardItemModel()
self.model.setHorizontalHeaderLabels(['Id', 'Serial Number', 'Length', 'Width', 'Height', 'Quantity'])
self.tableView.setModel(self.model)
self.tableView.horizontalHeader().setSectionResizeMode(1)
result = DS.select_all_crate(Con)
for row in result:
id = '{}'.format(row['Id'])
TableRow = (
QStandardItem('{}'.format(row['Id'])), QStandardItem(row['SerialNumber']), QStandardItem(row['Length']),
QStandardItem(row['Width']), QStandardItem(row['Height']), QStandardItem('1'))
self.model1.appendRow(TableRow)
# BoxResult = ds.select_all_box(conn)
BoxResult = DS.select_data(Con)
for row in BoxResult:
id = '{}'.format(row['Id'])
TableRow = (
QStandardItem('{}'.format(row['Id'])), QStandardItem(row['SerialNumber']), QStandardItem(row['Length']),
QStandardItem(row['Width']), QStandardItem(row['Height']), QStandardItem('1'))
self.model.appendRow(TableRow)
# self.actionNew.triggered.connect(self.addContact)
def addContact(self):
print('add item')
add = AddContact(self.model)
def start():
app = QtWidgets.QApplication([])
win = Example()
win.setFixedSize(1280, 720)
win.show()
sys.exit(app.exec())
Con.close()
# if __name__ == "__main__":
# start()