I'm trying to make a stock program with pyqt5, but when I click the add button, I get the python stopped error
Unsolved
General and Desktop
-
from PyQt5.QtWidgets import* from stock_python import Ui_MainWindow import sqlite3 class mysia_stock(QMainWindow): def __init__(self): super().__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.pushButton_tablo_ekle.clicked.connect(self.kayit_ekle) def kayit_ekle(self): komponentadi = self.ui.lineEdit_adi.text() komponentdegeri = self.ui.lineEdit_degeri.text() komponentturu = self.ui.lineEdit_turu.text() stokmiktari = int(self.ui.lineEdit_stok_miktari.text()) urunkategori = self.ui.comboBox_urun_kategori.currentText() try: baglanti = sqlite3.connect("urunler.db") islem = baglanti.cursor() baglanti.commit() ekle = "INSERT INTO urun VALUES(?,?,?,?,?)" islem.execute(ekle, (komponentadi, komponentdegeri, komponentturu, stokmiktari, urunkategori)) baglanti.commit() self.ui.statusbar.showMessage("Kayıt Başarılı", 2000) except ValueError: self.ui.statusbar.showMessage("Kayıt Başarısız", 2000) except sqlite3.OperationalError: self.ui.statusbar.showMessage("sqlite", 2000) uygulama = QApplication([]) pencere = mysia_stock() pencere.show() uygulama.exec_()
-
@fath_yasar
You do not do proper error checking, such as for opening the database or executing the query --- do so. Step through your code in a debugger, or put inprint()
statements to see where it gets to.