这是我代码的底部:
import sys
app = QtWidgets.QApplication(sys.argv)
w = Window(autocompleteList3, autocompleteList2)
w.show()
我需要能够同时导入autocompleteList3和autocompleteList2。然而,当我这样做时,我得到了“TypeError:init()接受2个位置参数,但给出了3个。”它只允许我单独使用autocompleteList3或autocompleteList2
下面是我的自动完成功能(如果有帮助):
class Window(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self, cList):
super().__init__()
self.setupUi(self)
self.cList = cList
self.Input_5.addItems(sorted(cList.keys()))
self.Input_5.activated[str].connect(self.onActivatedText)
class Window2(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self, cList):
super().__init__()
self.setupUi(self)
self.cList = cList
self.Input_7.addItems(sorted(cList.keys()))
self.Input_7.activated[str].connect(self.onActivatedText2)
@QtCore.pyqtSlot(str)
def onActivatedText(self, text):
self.Input_19.setText(self.cList[text][0])
self.Input_29.setText(self.cList[text][1])
self.Input_30.setText(self.cList[text][2])
self.Input_18.setText(self.cList[text][3])
@QtCore.pyqtSlot(str)
def onActivatedText2(self, text):
self.Input_19.setText(self.cList[text][0])
self.Input_29.setText(self.cList[text][1])
self.Input_30.setText(self.cList[text][2])
self.Input_18.setText(self.cList[text][3])
最后,这里是autocompleteList3(2看起来相同):
autocompleteList3 = {
'': ['','','','','','','','','','','','','','','','','',''],
'two': ['3332', '234234', 'test55', '3332', '234234', 'test55', '3332', '234234', 'test55', '3332', '234234', 'test55', '3332', '234234', 'test55', '3332', '234234', 'test55', 'test55'],
'one': ['3332', '234234', 'test55', '3332', '234234', 'test55', '3332', '234234', 'test55', '3332', '234234', 'test55', '3332', '234234', 'test55', '3332', '234234', 'test55', 'test55'],
}
with open('boxes.csv', mode='r') as csv_file:
csv_reader = csv.reader(csv_file)
for row in csv_reader:
autocompleteList2[row[0]] = [row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14], row[15], row[16], row[17], row[18], row[19]]
有人知道怎么做吗?我需要在同一窗口中具有两个从csv文件提取的自动完成功能。:/
我明白了。见下文
我不得不离开cList,将autocompleteList2分配到它的位置。工作完美。“尝试例外”通行证用于在处理空白单元格时防止崩溃
类窗口(QtWidgets.QMainWindow,Ui_MainWindow):
definit(自我,客户端): super().init()
相关问题 更多 >
编程相关推荐