Issue
My program pulls data from a hard-coded dictionary and also adds some from a .csv so when I select a last name in my lineEdit, two other input fields populate with an associated e-mail address and phone number.
When I click into my lineEdit and begin typing a name, the autocomplete feature doesn't activate. If I press enter after typing in a name that exists in my dictionary, my entire program crashes. However, if I first select the dropdown and pick any random name, it seems to activate my autocomplete and I can type in any other name, find it, and press enter to populate other fields.
dictionary:
autocompleteList2 = {
' ': [' ', ' '],
'Adams': ['[email protected]', '555-555-5555'],
How I manipulated my other inputs:
class Window(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.onActivatedText)
@QtCore.pyqtSlot(str)
def onActivatedText(self, text):
self.Input_8.setText(self.cList[text][0])
self.Input_9.setText(self.cList[text][1])
Dictionary linked:
if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
w = Window(autocompleteList2)
w.show()
app.setStyle('Fusion')
palette = QtGui.QPalette()
How can I get auto complete to activate as soon as I click into Input_7 (a lineEdit)?
Solution
Fixed by deleting the spaces:
autocompleteList2 = {
'': ['', '', ''],
}
It was crashing because I'd try entering data that wasn't there (space before name).
Answered By - ekhumoro
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.