Имам този код:
self.entriesx = self.generate_stringvars()
# Fill in the entry fields if a template is selected.
def autofill(self):
# Generate a dictionary of all the saved templates.
test_dictionary = self.build_test_dictionary()
# Retrive the selected qual name from the form.
self.coded_entry = self.comboBox.currentText()
entries = test_dictionary[self.coded_entry]
# Set each entry field in self.entriesx to the corresponding value
# from the template.
i_count = 0
for i in self.entriesx:
i.set(entries[i_count])
i_count += 1
# Reload the entry fields with their new values.
self.add_entry_fields()
Функцията autofill(self) автоматично попълва съответните записи в полетата за въвеждане въз основа на избран елемент от разгъващ се списък. Функцията за автоматично попълване също разчита на тази функция:
# Generate a list of string variables to store the entries.
def generate_stringvars(self):
temp_entriesx = []
count = 0
while count < 21:
temp_entriesx.append("")
count += 1
return temp_entriesx
Когато компилирам кода си, получавам грешка AttributeError: 'str' object has no attribute 'set' for i.set(entries[i_count]) в моята функция за автоматично попълване. Как да го поправя?
Редактиране: Това е последващ въпрос към тази публикация.