Aug-23-2019, 10:16 AM
(Aug-23-2019, 07:22 AM)Axel_Erfurt Wrote: did you not show the MainWindow() ?
if __name__ == '__main__': connectDB() app = QtWidgets.QApplication(sys.argv) MainApplication = MainWindow() MainApplication.show() ## show main window app.exec()
Yeah i've set it to show through my setupUI method, the complete code is below ...
from PyQt5 import QtWidgets import mysql.connector import sys from fuzzywuzzy import fuzz, process class MainWindow(QtWidgets.QWidget): def __init__(self): super(MainWindow, self).__init__() self.client_name = QtWidgets.QLineEdit() self.check_button = QtWidgets.QPushButton("Add Client to BABAR AKRAM") self.check_button.clicked.connect(self.addName) self.setupUI() def setupUI(self): container = QtWidgets.QGridLayout() container.addWidget(QtWidgets.QLabel("Client Name"), 0, 0) container.addWidget(self.client_name, 0, 1) container.addWidget(self.check_button, 1, 0, 1, 2) self.setWindowTitle("For Updating Client List Manually") self.setLayout(container) self.show() def addName(self): print("Add button clicked") def connectDB(): try: connection = mysql.connector.connect(host='######', user='######', password='######') cursor = connection.cursor() cursor.execute('USE client_list;') except: msg = QtWidgets.QMessageBox(3, "Warning", "Please check the internet connection", QtWidgets.QMessageBox.Ok) msg.exec() if __name__ == '__main__': connectDB() app = QtWidgets.QApplication(sys.argv) MainApplication = MainWindow() app.exec()