Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

tkinter - Get entry of python Combobox and work with that data

I built a program around two Comboboxes, where users can enter a number. The dropdown consists of the first column of the csv file below. After the user entered the number in the Combobox, I then take that number with .get() and search for it in the csv to get a related number to display in CB2. Combobox 2 is dependant on Combobox 1 and only displays the third column related to that respective number.

Everything works fine when the user selects a number in the dropdown menu, but not when he types that exact same number in the Combobox. The second Combobox doesn't update and shows up blank:1 The rest of the program dependant on those entries works just fine either way

Here's the code:

def updatecombo(event=None):
    eingabe_motor = eingabefeld_motor.get()
    filter_motorttnr = filter(lambda a: eingabe_motor in a, daten)
    liste_filter_motorttnr = list(filter_motorttnr)
    eingabefeld_index["values"] = [x[2] for x in liste_filter_motorttnr]
    eingabefeld_index.update()

eingabefeld_motor = ttk.Combobox(root, value=motorttnr[1:])
eingabefeld_motor.bind('<<ComboboxSelected>>', updatecombo)
eingabefeld_index = ttk.Combobox(root)

What can I do to fix this issue?

Example of the CSV:

130822060;060_Motor.gif;1K1;5;060_Lage_1K1.gif;10;1K1_1_Kunststoffbox.gif 130822060;060_Motor.gif;U30;52;060_Lage_U30_Text.gif;780;1K1_Kunststoffbox_gruene_Stollen_Text.gif

130822061;061_Motor.gif;U30;52;061_Lage_U30_Text.gif;780;1K1_Kunststoffbox_gruene_Stollen_Text.gif

130822061;061_Motor.JPG;1K1;52;061_Lage_1K1.JPG;780;1K1_1_Kunststoffbox.gif

question from:https://stackoverflow.com/questions/65905516/get-entry-of-python-combobox-and-work-with-that-data

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...