I created a combobox to show a list of values out of a sqlite database.
If I sent the values to the combobox, the list will shown. The problem is, that the field will not filled with the first value and stay empty until I select on item of out of the drop menu.
Could I set a value to be displayed directly?
Here my code snippet:
self.e_business = ttk.Combobox(address_frame, width = 40)
self.e_business.grid(row=3, column=1, columnspan=2, padx=(5,20), pady=(15,5), sticky='WE')
The function which send the values:
def show_name_search(self, event):
...
widget = event.widget
selection = widget.curselection()
indName = widget.get(selection[0])
print(indName)
print("selktierter Wert: {}".format(indName))
self.realName.set(indName)
connection = sqlite3.connect(select_connect_db)
print('Database connected.')
with connection:
cursor = connection.cursor()
cursor.execute("SELECT number, type, prio, id, uniqueid FROM numbers WHERE realName='"+indName+"';")
data = cursor.fetchall()
print(data)
cache = []
for row in data:
cache.append(row[0])
self.e_business['values'] = cache
The cache list looks like:
CACHE: ['081191310912', '071109131090', '01754123353']
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…