What is this means? my code is running and working well
-
def buttons(self):
#Search function
self.search = QLineEdit(self)
self.search.resize(150,25)
self.searchLabel = QLabel("Search",self)
self.searchLabel.move(10,10)
self.search.move(90,10)
self.searchbtn = QtGui.QPushButton("SEARCH",self)
self.searchbtn.clicked.connect(self.searchFunction)
self.searchbtn.resize(self.searchbtn.minimumSizeHint())
self.searchbtn.move(160,40)
#End of search function#start input 1 self.Date_received = QtGui.QLineEdit(self) self.Date_received.resize(150,25) self.InputLabel = QtGui.QLabel("Date received",self) self.Date_received.move(90,100) self.InputLabel.move(10,99) #end Input 1 #start input 2 self.query = QSqlQuery("SELECT name FROM names_delta") self.Received_by = QComboBox(self) self.Received_by.currentIndexChanged.connect(self.inputFunction) self.Received_by.resize(150,25) self.Input2Label = QLabel("Received by",self) self.Input2Label.move(10,130) self.Received_by.move(90,130) while(self.query.next()): self.Received_by.addItem(self.query.value(0).toString()) #end input 2 #start input 3 self.Delivered_by = QtGui.QLineEdit(self) self.Delivered_by.resize(150,25) self.Input3Label = QtGui.QLabel("Delivered by",self) self.Input3Label.move(10,160) self.Delivered_by.move(90,160) #end input 3 #start input 4 self.Invoice = QtGui.QLineEdit(self) self.Invoice.resize(150,25) self.Input4Label = QtGui.QLabel("Invoice #",self) self.Input4Label.move(10,190) self.Invoice.move(90,190) #end input 4 #start input 5 self.Purchase_order = QtGui.QLineEdit(self) self.Purchase_order.resize(150,25) self.Input5Label = QtGui.QLabel("Purchase Order",self) self.Input5Label.move(10,220) self.Purchase_order.move(90,220) #end input 5 #start input 6 self.Model = QtGui.QLineEdit(self) self.Model.resize(150,25) self.Input6Label = QtGui.QLabel("Model",self) self.Input6Label.move(10,250) self.Model.move(90,250) #end input 6 #start input 7 self.Specification = QtGui.QLineEdit(self) self.Specification.resize(150,25) self.Input7Label = QtGui.QLabel("Specification",self) self.Input7Label.move(10,280) self.Specification.move(90,280) #end input 7 #start input 8 self.Quantity = QtGui.QLineEdit(self) self.Quantity.resize(150,25) self.Input8Label = QtGui.QLabel("Quantity",self) self.Input8Label.move(10,310) self.Quantity.move(90,310) #end input 8 #start input 9 self.Serial = QtGui.QLineEdit(self) self.Serial.resize(150,25) self.Input9Label = QtGui.QLabel("Serial #",self) self.Input9Label.move(10,340) self.Serial.move(90,340) #end input 9 #start input 10 self.Sticker = QtGui.QLineEdit(self) self.Sticker.resize(150,25) self.Input10Label = QtGui.QLabel("Sticker #",self) self.Input10Label.move(10,370) self.Sticker.move(90,370) #end input 10 #start input 11 self.Asset = QtGui.QLineEdit(self) self.Asset.resize(150,25) self.Input11Label = QtGui.QLabel("Asset #",self) self.Input11Label.move(10,400) self.Asset.move(90,400) #end input 11 #start input 12 self.Warranty_Expiry = QtGui.QLineEdit(self) self.Warranty_Expiry.resize(150,25) self.Input12Label = QtGui.QLabel("Warranty Expiry",self) self.Input12Label.move(10,430) self.Warranty_Expiry.move(90,430) #end input 12 # self.Issued_to = QtGui.QLineEdit(self) self.Issued_to.resize(150,25) self.Input16Label = QtGui.QLabel("Issued to",self) self.Input16Label.move(10,460) self.Issued_to.move(90,460) # #start input 13 self.Site = QtGui.QLineEdit(self) self.Site.resize(150,25) self.Input13Label = QtGui.QLabel("Site",self) self.Input13Label.move(10,490) self.Site.move(90,490) #end input 13 #start input 14 self.Department = QtGui.QLineEdit(self) self.Department.resize(150,25) self.Input14Label = QtGui.QLabel("Department",self) self.Input14Label.move(10,520) self.Department.move(90,520) #end input 14 #start input 15 self.Amount = QtGui.QLineEdit(self) self.Amount.resize(150,25) self.Input15Label = QLabel("Amount",self) self.Input15Label.move(10,550) self.Amount.move(90,550) #end input 15 #Input submit self.Submitbtn = QtGui.QPushButton("SUBMIT",self) self.Submitbtn.clicked.connect(self.inputFunction) self.Submitbtn.resize(self.Submitbtn.minimumSizeHint()) self.Submitbtn.move(160,580) #Input end self.show() def searchFunction(self): SEARCH = self.search.text() if SEARCH == "": print "Enter something" else: print (SEARCH) def inputFunction(self): DATE_RECEIVED = self.Date_received.text() RECEIVED_BY = self.Received_by.currentText() DELIVERED_BY = self.Delivered_by.text() INVOICE = self.Invoice.text() PURCHASE_ORDER = self.Purchase_order.text() MODEL = self.Model.text() SPECIFICATION = self.Specification.text() QUANTITY = self.Quantity.text() SERIAL = self.Serial.text() STICKER = self.Sticker.text() ASSET = self.Asset.text() WARRANTY_EXPIRY = self.Warranty_Expiry.text() ISSUED_TO = self.Issued_to.text() SITE = self.Site.text() DEPARTMENT = self.Department.text() AMOUNT = self.Amount.text() print RECEIVED_BY if DATE_RECEIVED == "": print "full up all form" else: self.con = mysql.connector.connect(user="root",password="admingelo",host="localhost",database="incoming_mac") self.manager = self.con.cursor() self.insert_this_data = ("""INSERT INTO incoming_mac_records(DATE_RECEIVED,RECEIVED_BY,DELIVERED_BY,INVOICE_NUMBER) VALUES('%s','%s','%s',%s)"""%(DATE_RECEIVED,RECEIVED_BY,DELIVERED_BY,str(INVOICE))) self.manager.execute(self.insert_this_data) self.con.commit() self.con.close() print "Okay na bes!" self.projectModel.setQuery("select * from incoming_mac_records",self.db) self.projectView = QTableView(self) self.projectView.setModel(self.projectModel) self.projectView.resizeColumnsToContents() self.projectView.setGeometry(250,10,940,680)
-
You code is not clear. Are you defining all these methods in the
__init__
function ? -
import sys import os from PyQt4.QtGui import * from PyQt4.QtCore import * from PyQt4.QtSql import * from PyQt4 import QtGui,QtCore import mysql.connector class Window(QtGui.QMainWindow): def __init__(self): super(Window, self).__init__() self.setGeometry(50,50,1200,700) self.setWindowTitle("Inventory and Monitoring System") self.setWindowIcon(QtGui.QIcon('Pictures/delta.png')) QApplication.setStyle(QStyleFactory.create('Cleanlooks')) self.db = QSqlDatabase.addDatabase("QMYSQL") self.db.setHostName("localhost") self.db.setDatabaseName("incoming_mac") self.db.setUserName("root") self.db.setPassword("admingelo") self.db.open() self.projectModel = QSqlQueryModel() self.projectModel.setQuery("select * from incoming_mac_records",self.db) self.projectView = QTableView(self) self.projectView.setModel(self.projectModel) self.projectView.resizeColumnsToContents() self.projectView.setGeometry(250,10,940,680) self.buttons() def buttons(self): #Search function self.search = QLineEdit(self) self.search.resize(150,25) self.searchLabel = QLabel("Search",self) self.searchLabel.move(10,10) self.search.move(90,10) self.searchbtn = QtGui.QPushButton("SEARCH",self) self.searchbtn.clicked.connect(self.searchFunction) self.searchbtn.resize(self.searchbtn.minimumSizeHint()) self.searchbtn.move(160,40) #End of search function #start input 1 self.Date_received = QtGui.QLineEdit(self) self.Date_received.resize(150,25) self.InputLabel = QtGui.QLabel("Date received",self) self.Date_received.move(90,100) self.InputLabel.move(10,99) #end Input 1 #start input 2 self.query = QSqlQuery("SELECT name FROM names_delta") self.Received_by = QComboBox(self) self.Received_by.currentIndexChanged.connect(self.inputFunction) self.Received_by.resize(150,25) self.Input2Label = QLabel("Received by",self) self.Input2Label.move(10,130) self.Received_by.move(90,130) while(self.query.next()): self.Received_by.addItem(self.query.value(0).toString()) #end input 2 #start input 3 self.Delivered_by = QtGui.QLineEdit(self) self.Delivered_by.resize(150,25) self.Input3Label = QtGui.QLabel("Delivered by",self) self.Input3Label.move(10,160) self.Delivered_by.move(90,160) #end input 3 #start input 4 self.Invoice = QtGui.QLineEdit(self) self.Invoice.resize(150,25) self.Input4Label = QtGui.QLabel("Invoice #",self) self.Input4Label.move(10,190) self.Invoice.move(90,190) #end input 4 #start input 5 self.Purchase_order = QtGui.QLineEdit(self) self.Purchase_order.resize(150,25) self.Input5Label = QtGui.QLabel("Purchase Order",self) self.Input5Label.move(10,220) self.Purchase_order.move(90,220) #end input 5 #start input 6 self.Model = QtGui.QLineEdit(self) self.Model.resize(150,25) self.Input6Label = QtGui.QLabel("Model",self) self.Input6Label.move(10,250) self.Model.move(90,250) #end input 6 #start input 7 self.Specification = QtGui.QLineEdit(self) self.Specification.resize(150,25) self.Input7Label = QtGui.QLabel("Specification",self) self.Input7Label.move(10,280) self.Specification.move(90,280) #end input 7 #start input 8 self.Quantity = QtGui.QLineEdit(self) self.Quantity.resize(150,25) self.Input8Label = QtGui.QLabel("Quantity",self) self.Input8Label.move(10,310) self.Quantity.move(90,310) #end input 8 #start input 9 self.Serial = QtGui.QLineEdit(self) self.Serial.resize(150,25) self.Input9Label = QtGui.QLabel("Serial #",self) self.Input9Label.move(10,340) self.Serial.move(90,340) #end input 9 #start input 10 self.Sticker = QtGui.QLineEdit(self) self.Sticker.resize(150,25) self.Input10Label = QtGui.QLabel("Sticker #",self) self.Input10Label.move(10,370) self.Sticker.move(90,370) #end input 10 #start input 11 self.Asset = QtGui.QLineEdit(self) self.Asset.resize(150,25) self.Input11Label = QtGui.QLabel("Asset #",self) self.Input11Label.move(10,400) self.Asset.move(90,400) #end input 11 #start input 12 self.Warranty_Expiry = QtGui.QLineEdit(self) self.Warranty_Expiry.resize(150,25) self.Input12Label = QtGui.QLabel("Warranty Expiry",self) self.Input12Label.move(10,430) self.Warranty_Expiry.move(90,430) #end input 12 # self.Issued_to = QtGui.QLineEdit(self) self.Issued_to.resize(150,25) self.Input16Label = QtGui.QLabel("Issued to",self) self.Input16Label.move(10,460) self.Issued_to.move(90,460) # #start input 13 self.Site = QtGui.QLineEdit(self) self.Site.resize(150,25) self.Input13Label = QtGui.QLabel("Site",self) self.Input13Label.move(10,490) self.Site.move(90,490) #end input 13 #start input 14 self.Department = QtGui.QLineEdit(self) self.Department.resize(150,25) self.Input14Label = QtGui.QLabel("Department",self) self.Input14Label.move(10,520) self.Department.move(90,520) #end input 14 #start input 15 self.Amount = QtGui.QLineEdit(self) self.Amount.resize(150,25) self.Input15Label = QLabel("Amount",self) self.Input15Label.move(10,550) self.Amount.move(90,550) #end input 15 #Input submit self.Submitbtn = QtGui.QPushButton("SUBMIT",self) self.Submitbtn.clicked.connect(self.inputFunction) self.Submitbtn.resize(self.Submitbtn.minimumSizeHint()) self.Submitbtn.move(160,580) #Input end self.show() def searchFunction(self): SEARCH = self.search.text() if SEARCH == "": print "Enter something" else: print (SEARCH) def inputFunction(self): DATE_RECEIVED = self.Date_received.text() RECEIVED_BY = self.Received_by.currentText() DELIVERED_BY = self.Delivered_by.text() INVOICE = self.Invoice.text() PURCHASE_ORDER = self.Purchase_order.text() MODEL = self.Model.text() SPECIFICATION = self.Specification.text() QUANTITY = self.Quantity.text() SERIAL = self.Serial.text() STICKER = self.Sticker.text() ASSET = self.Asset.text() WARRANTY_EXPIRY = self.Warranty_Expiry.text() ISSUED_TO = self.Issued_to.text() SITE = self.Site.text() DEPARTMENT = self.Department.text() AMOUNT = self.Amount.text() print RECEIVED_BY if DATE_RECEIVED == "": print "full up all form" else: self.con = mysql.connector.connect(user="root",password="admingelo",host="localhost",database="incoming_mac") self.manager = self.con.cursor() self.insert_this_data = ("""INSERT INTO incoming_mac_records(DATE_RECEIVED,RECEIVED_BY,DELIVERED_BY,INVOICE_NUMBER) VALUES('%s','%s','%s',%s)"""%(DATE_RECEIVED,RECEIVED_BY,DELIVERED_BY,str(INVOICE))) self.manager.execute(self.insert_this_data) self.con.commit() self.con.close() print "Okay na bes!" self.projectModel.setQuery("select * from incoming_mac_records",self.db) self.projectView = QTableView(self) self.projectView.setModel(self.projectModel) self.projectView.resizeColumnsToContents() self.projectView.setGeometry(250,10,940,680) def run(): app = QtGui.QApplication(sys.argv) GUI = Window() sys.exit(app.exec_()) run()
[edit: added missing coding tags SGaist]
-
@Aquarius171 said in What is this means? my code is running and working well:
DELIVERED_BY = self.Delivered_by.text()
It's caused by this line. Basically it is saying that the
self
object does not have a variable/property with the nameDelivered_by
. Check the object referred to asself
for that property. You probably misspelled it or didn't define it properly. -
@ambershark Thank you for the help i already solved the problem
-
What was it ?
-
That I understood and I'm happy that you solved it. The question was: what did you do to fix your code ?