-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomers.py
75 lines (59 loc) · 2.82 KB
/
Customers.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
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'grammes.ui'
#
# Created by: PyQt5 UI code generator 5.15.2
#
# 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.
import mysql.connector
from PyQt5 import QtCore, QtGui, QtWidgets
import mysql.connector
from PyQt5.QtWidgets import QVBoxLayout, QPushButton
class Ui_OtherWindow(object):
def loadData(self):
cnx = mysql.connector.connect(host="remotemysql.com", user="4Re4u1cLi1", password="Gto4QD5Kx7",database="4Re4u1cLi1")
mycursor = cnx.cursor()
mycursor.execute("SELECT * FROM Πελάτης")
result = mycursor.fetchall()
self.tableWidget.setRowCount(0)
for row_number, row_data in enumerate(result):
self.tableWidget.insertRow(row_number)
for column_number,data in enumerate(row_data):
self.tableWidget.setItem(row_number,column_number, QtWidgets.QTableWidgetItem(str(data)))
cnx.close()
def setupUi1(self, MainWindow):
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget_new")
MainWindow.setCentralWidget(self.centralwidget)
self.tableWidget = QtWidgets.QTableWidget(self.centralwidget)
self.tableWidget.setGeometry(QtCore.QRect(5, 11, 621, 531))
#self.tableWidget.setRowCount(19)
self.tableWidget.setColumnCount(3)
self.tableWidget.setObjectName("tableWidget")
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(2, item)
self.loadData()
self.retranslateUi1(MainWindow)
def retranslateUi1(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
_translate = QtCore.QCoreApplication.translate
item = self.tableWidget.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "Α.Δ.Τ."))
item = self.tableWidget.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Όνομα"))
item = self.tableWidget.horizontalHeaderItem(2)
item.setText(_translate("MainWindow", "e-mail"))
#self.btn_add.setText(_translate("MainWindow", "Add"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
OtherWindow = QtWidgets.QMainWindow()
ui = Ui_OtherWindow()
ui.setupUi1(OtherWindow)
OtherWindow.show()
sys.exit(app.exec_())