감사 엘리 .. 여기
내가 가진 것입니다. 그리고 네, 함수 'checkChosenCity'가 프로그램 내의 다른 곳에서 호출되지 않았는지 확인했습니다.
이상적인 해결책이 아닌 빠른 수정으로 문제를 피하기 위해 'checkChosenCity'함수를 사용했습니다. 따라서이 함수가 'connect'에 의해 잘못 활성화되면 도시 이름이 실제로 선택되었는지 확인한 다음 도시 이름이없는 경우 뾰족한 프로세스가 실행되지 않아 시스템 충돌을 피할 수 있습니다.
다음
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
은 다음과 같습니다
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
가 콤보 상자에 고객 이름 목록을로드하는 기능입니다 : 여기
은 콤보 상자에 도시 목록을로드하는 기능입니다 고객 이름이 선택되었는지 검사하는 함수 :
def checkChosenCustomer(self):
self.customerName=self.comboCustomer.currentText()
print "the customer chosen is:"
print "%s" % self.customerName
self.loadcomboCity(self.customerName)
콤보 상자에 목록에서 선택 일부 도시 : 정말
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)
하지 이상적인 솔루션 : 여기
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
콤보 박스 이벤트를 연결하는 주요 기능입니다. 그러나 이상한 연결 이벤트가 잘못 작동되고 있음을 알아내는 데 몇 시간을 소비해야한다는 것은 상당히 재미 있습니다.
다른 설명을 발견하면 저희에게 알려주십시오.
문제를 설명하는 작은 예제를 모두 분리하십시오. –