-
Notifications
You must be signed in to change notification settings - Fork 0
/
select_table_to_process.py
113 lines (93 loc) · 4.72 KB
/
select_table_to_process.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
# Form implementation generated from reading ui file 'select_table_to_process.ui'
#
# Created by: PyQt6 UI code generator 6.3.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt6 import QtCore, QtGui, QtWidgets
from PyQt6.QtCore import Qt
class Ui_SelectTableToProcess(object):
selected_tables = []
def setupUi(self, SelectTableToProcess, MainWindow, source_tables ):
init_selected_tables = MainWindow.selected_tables_list
#print('2nd win init')
#print(init_selected_tables)
self.selected_tables=[]
self.tableModel = QtGui.QStandardItemModel(SelectTableToProcess)
self.tableModel.removeRows( 0, self.tableModel.rowCount() )
self.tableModel.itemChanged.connect(self.itemChanged)
self.tableModel.setHorizontalHeaderLabels(['Source Tables'])
for source_table in source_tables:
item = QtGui.QStandardItem(source_table)
item.setCheckable(True)
if source_table in init_selected_tables:
self.selected_tables.append(source_table)
item.setCheckState(Qt.CheckState.Checked)
self.tableModel.appendRow(item)
SelectTableToProcess.setObjectName("SelectTableToProcess")
SelectTableToProcess.resize(397, 520)
self.centralwidget = QtWidgets.QWidget(SelectTableToProcess)
self.centralwidget.setObjectName("centralwidget")
self.select_tables = QtWidgets.QTableView(self.centralwidget)
self.select_tables.setModel(self.tableModel)
self.select_tables.resizeColumnsToContents()
self.select_tables.setGeometry(QtCore.QRect(20, 60, 360, 360))
font = QtGui.QFont()
font.setPointSize(12)
self.select_tables.setFont(font)
self.select_tables.setObjectName("select_tables")
self.select_tables.resizeColumnsToContents()
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(20, 460, 93, 28))
font = QtGui.QFont()
font.setPointSize(12)
self.pushButton.setFont(font)
self.pushButton.setObjectName("pushButton")
self.pushButton.clicked.connect(lambda: self.get_selected_tables(MainWindow))
self.pushButton.clicked.connect(SelectTableToProcess.close)
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(20, 20, 221, 16))
font = QtGui.QFont()
font.setPointSize(12)
self.label.setFont(font)
self.label.setObjectName("label")
SelectTableToProcess.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(SelectTableToProcess)
self.menubar.setGeometry(QtCore.QRect(0, 0, 397, 26))
self.menubar.setObjectName("menubar")
SelectTableToProcess.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(SelectTableToProcess)
self.statusbar.setObjectName("statusbar")
SelectTableToProcess.setStatusBar(self.statusbar)
self.retranslateUi(SelectTableToProcess)
QtCore.QMetaObject.connectSlotsByName(SelectTableToProcess)
def itemChanged(self, item):
#print('change self' , self.selected_tables)
if item.checkState() == Qt.CheckState.Checked :
self.selected_tables.append(item.text())
if item.checkState() == Qt.CheckState.Unchecked :
self.selected_tables.remove(item.text())
#print("Item {!r} checkState: {}".format(item.text(), item.checkState()))
#print(self.selected_tables)
def retranslateUi(self, SelectTableToProcess):
_translate = QtCore.QCoreApplication.translate
SelectTableToProcess.setWindowTitle(_translate("SelectTableToProcess", "Select Table to Process"))
self.pushButton.setText(_translate("SelectTableToProcess", "Finish"))
self.label.setText(_translate("SelectTableToProcess", "Select Tables to Process"))
def get_selected_tables(self,MainWindow):
#print('self',self.selected_tables)
#print('parent' , MainWindow.selected_tables_list)
MainWindow.selected_tables_list = self.selected_tables
MainWindow.update_selected_tables()
return self.selected_tables
# if __name__ == "__main__":
# import sys
# source_tables=['aa','bb', 'cc']
# selected_tables=['bb']
# app = QtWidgets.QApplication(sys.argv)
# SelectTableToProcess = QtWidgets.QMainWindow()
# ui = Ui_SelectTableToProcess()
# ui.setupUi(SelectTableToProcess,source_tables = source_tables, selected_tables = selected_tables)
# tt = SelectTableToProcess.show()
# print(tt)
# sys.exit(app.exec())