I have been coding for two months. I want to use tkinter and Listbox and access variable "attached" to specific loop in a for loop.
Here is my code so far:
from tkinter import *
root = Tk()
listbox = Listbox(root)
listbox.pack()
number = 10
for i in range(number):
listbox.insert(END, i)
# here letter A, B, C, etc.?
def get_letter():
print(listbox.get(listbox.curselection()))
btn = Button(root, text="Show letter from row", command=lambda: get_letter())
btn.pack()
mainloop()
In this program I would like to give (and show) every row in listbox a number value and corresponding letter value/variable in the backend (0 to A, 1 to B, etc.). At runtime I want to click a number, then press button and thus printing the letter. I commented the line where I suppose the letter value would be inserted, but I can't imagine a method. How would I go about doing this?