Python Forum
PyQt5 : Interpreter Crashes While Initializing Message Box
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyQt5 : Interpreter Crashes While Initializing Message Box
#3
(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()
Reply


Messages In This Thread
RE: PyQt5 : Interpreter Crashes While Initializing Message Box - by iMuny - Aug-23-2019, 10:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  GUI crashes flash77 3 963 Jul-26-2023, 05:09 PM
Last Post: flash77
  [Tkinter] Clicking on the button crashes the TK window ODOshmockenberg 1 2,273 Mar-10-2022, 05:18 PM
Last Post: deanhystad
  [PyQt] App crashes when reopening a subwindow JayCee 13 5,148 Aug-04-2021, 01:51 AM
Last Post: JayCee
  [PyGUI] My GUI crashes after command MLGpotato 1 1,918 Feb-21-2021, 03:17 PM
Last Post: deanhystad
  [PyQt] PyQT5 Thread crashes after a while Suresh 0 2,005 Jul-21-2020, 07:53 AM
Last Post: Suresh
  Huge code problems (buttons(PyQt5),PyQt5 Threads, Windows etc) ZenWoR 0 2,859 Apr-06-2019, 11:15 PM
Last Post: ZenWoR

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020