更新的代碼片段: 我已更新爲'self'。約定而不是全局的,但仍然有唯一的值返回了在類級別上分配的空字符串,但是如果刪除了該字符串,則會引發錯誤。NameError:名稱未定義
class MainDialog(QWidget, qcDbWidget4.Ui_qcQueryWidget):
dbDir = ''
DbSelection = ''
dbPath = ''
TabSelection = ''
exportDir = ''
exportFileName = ''
def __init__(self, parent=None):
super(MainDialog, self).__init__(parent)
self.setupUi(self)
self.connect(self.dbDirSelect, SIGNAL("clicked()"), self.getDirFileNames)
self.connect(self.dbSelectButton, SIGNAL('clicked()'), self.selectDb)
self.connect(self.tabSelectButton, SIGNAL('clicked()'), self.selectTab)
self.connect(self.exportDirSelect, SIGNAL("clicked()"), self.getExportDir)
self.connect(self.exportButton, SIGNAL("clicked()"), self.setExportName)
self.connect(self.querySubmitButton, SIGNAL("clicked()"), self.setQueryParams)
self.connect(self.querySubmitButton, SIGNAL("clicked()"), self.dbQuery)
def getDirFileNames(self):
self.dbDir = str(QFileDialog.getExistingDirectory(self))
self.dbDirDisplay.setText(self.dbDir)
dbFileList = []
for root, dirs, files in os.walk(self.dbDir):
for file in files:
if file.endswith('.db'):
dbFileList.append(file)
self.dbSelection.addItems(dbFileList)
哪條線返回錯誤?你看過其他什麼答案? – jmoon
請勿使用'global'。您可能正在尋找'self.qcLevelCode'。 – Ryan
它似乎來自:queryStatement =「SELECT * FROM」+ qcTabSelect +「WHERE」+ qcLevelSelect向底部 – RGETLB