Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. I'm trying to make a stock program with pyqt5, but when I click the add button, I get the python stopped error
Forum Updated to NodeBB v4.3 + New Features

I'm trying to make a stock program with pyqt5, but when I click the add button, I get the python stopped error

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 215 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fath_yasar
    wrote on last edited by
    #1
    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_()
    
    JonBJ 1 Reply Last reply
    0
    • F fath_yasar
      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_()
      
      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @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 in print() statements to see where it gets to.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved