Thanks Eli..
Here is what I have:
combo1 : [customernames] - pick a customer.
combo2 : [cityList] - pick a city for the chosen customer.
combo3 : [emploeeList] - load employees for that city, given the chosen customer.
What I find out is that, even when no city is chosen, the combox-box for city is activated. And yes, I have checked if the function 'checkChosenCity' is not called anywhere else inside the program.
As a quick fix, not the ideal solution, I put a condition to avoid the problem into the function 'checkChosenCity'. So, now when this function is wrongly activated by 'connect', it checks if a city name was really selected, if none, then the pointed process doesn't run avoiding the system to crash.
Here is the function that loads the city list into combo-box:
def loadcomboCity(self,customerName):
if customerName == " ":
"""no customer was chosen yet - list of city empty"""
id=0
CityName=" "
self.addcomboCity(id,CityName)
else:
"""for this customerName - load his city list"""
self.loadCityList_mysql(customerName)
lin=0
""" the data is imported from mysql class into self.db.matrix"""
for row in self.db.matrix:
id=lin
cityname=self.db.matrix[lin][0]
print "city name = %s" % cityname
self.addcomboCity(id,cityname)
lin=lin+1
Here is the function that loads the customer-names list into combo-box:
def loadComboCustomer(self):
"""queries customerList into self.connexDB.matrix"""
self.loadCustomerList_mysql()
lin=0
""" the data is imported from mysql class into self.db.matrix"""
for row in self.connexDB.matrix:
id=lin
customername=self.connexDB.matrix[lin][0]
self.addcomboCustomer(id,customername)
lin=lin+1
Here is the function that checkes if the a customer name was chosen:
def checkChosenCustomer(self):
self.customerName=self.comboCustomer.currentText()
print "the customer chosen is:"
print "%s" % self.customerName
self.loadcomboCity(self.customerName)
Here is the function that checks if some city chosen from list into combo-box:
def checkChosenCity(self):
self.CityName=self.comboCity.currentText()
print "the City chosen is:"
print "value of City = %s" % self.CityName
if self.CityName == '':
print "empty"
else:
"""for this city - load the respective customer employee list"""
self.buildListOfEmployees_mysql(self.CityName)
""" the data is imported from mysql class into self.db.matrix"""
for row in self.db.matrix:
id=lin+1
personname=self.db.matrix[lin][0]
print "person name = %s" % personname
self.addcomboPerson(id,personname)
lin=lin+1
Here is the main function that connect combo-box events:
def options(self):
self.comboCustomer = QtGui.QComboBox(self.boxBooking)
self.comboCustomer.setGeometry(QtCore.QRect(60, 60, 521, 22))
self.loadComboCustomer()
QtCore.QObject.connect(self.comboCustomer, QtCore.SIGNAL("currentIndexChanged(QString)"), self.checkChosenCustomer)
self.comboCity = QtGui.QComboBox(self.boxBooking)
self.comboCity.setGeometry(QtCore.QRect(60, 120, 521, 22))
self.loadcomboCity(self.customerName)
QtCore.QObject.connect(self.comboCity, QtCore.SIGNAL("currentIndexChanged(QString)"), self.checkChosenCity)
Not the ideal solution really. But, quite funny to have to spend hours to find out that such a strange connect event is being wrongly self-activated.
If you discover any other explanation, just let us know.