I am working on a project. I set a toplevel, a listbox and textbox on the toplevel. I want to have a function that is called when I click on one of the elements of the list, and then I want to get the index of the selected element, and update the textbox. Any ideas?
This is the code I have, but it doesn't do what I want it to do:
def helpInitialize():
help = Toplevel()
help.title("Help")
help.geometry("1000x650")
help.resizable(0,0)
helpFiles= []
listy = Scrollbar(help)
listy.place(x=143, y=20, height=565)
listHelp = Listbox(help, height=35, width=20)
listHelp.place(x=20, y=20)
listHelp.config(yscrollcommand=listy.set)
listy.config(command=listHelp.yview)
texty = Scrollbar(help)
texty.place(x= 977, y= 20, height = 565)
textx = Scrollbar(help,orient= HORIZONTAL)
textx.place(x = 175, y= 583, width = 800)
helpText = Text(help, bg="white", height=35, width=100)
helpText.place(x=175, y=20)
helpText.configure(state="disabled")
helpText.config(yscrollcommand=texty.set, xscrollcommand=textx.set)
texty.config(command=helpText.yview)
textx.config(command=helpText.xview)
listHelp.bind("<Button-1>", theFunction)
def theFunction(event):
print(listHelp.get(listHelp.curselection()))