Lien vers mon code complet: https://www.dropbox.com/s/0tdnm2yd8038fwh/additem.py?dl=0AttributeError: objet 'Ui_Dialog' n'a pas d'attribut 'lineEdit_3'
Ceci est l'erreur que je reçois:
File "C:/Users/Lloyd/Desktop/Python Projects/stock/additem.py", line 187, in <module>
ui = Ui_Dialog()
File "C:/Users/Lloyd/Desktop/Python Projects/stock/additem.py", line 23, in __init__
self.setupUi(self)
File "C:/Users/Lloyd/Desktop/Python Projects/stock/additem.py", line 66, in setupUi
self.buttonBox.accepted.connect(self.accept())
File "C:/Users/Lloyd/Desktop/Python Projects/stock/additem.py", line 169, in accept
brandName = self.lineEdit_3.text()
AttributeError: 'Ui_Dialog' object has no attribute 'lineEdit_3'
Tout va bien avant d'ajouter:
self.buttonBox.accepted.connect(self.accept())
appel à cette méthode:
def accept(self):
conn = sqlite3.connect('inventory.db')
c = conn.cursor()
unix = time.time()
dateUpdated = datetime.datetime.fromtimestamp(unix).strftime('%Y-%m-%d %H:%M:%S')
company = self.lineEdit_2.text()
brandName = self.lineEdit_3.text()
genericName = self.lineEdit_4.text()
purchasePrice = self.lineEdit_5.text()
category = self.lineEdit_6.text()
sellingPrice = purchasePrice * sellingFactor
quantity = self.lineEdit_7.text()
#dosageForm = self.lineEdit_9.text()
expiryDate = self.lineEdit_10.text()
c.execute(
"INSERT INTO inventory(dateUpdated, company, brandName, genericName, category, purchasePrice, sellingPrice, quantity, expiryDate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
(dateUpdated, company, brandName, genericName, category, purchasePrice, sellingPrice, quantity, expiryDate))
conn.commit()
C'est le reste du code:
app = QtGui.QApplication(sys.argv)
window = QtGui.QDialog()
ui = Ui_Dialog()
ui.setupUi(window)
window.show()
sys.exit(app.exec_())
Sans voir 'C:/Users/Lloyd/Bureau/Python Projects/stock/additem.py', il est difficile de deviner. Mais il n'y a probablement pas d'attribut de ce type. –
@ThomasKilian Il a déjà été répondu par eyllanesc. – lloydyu24