I'm creating labels dynamically in a for loop using tkinter. I don't know how many labels will be created, but on clicking of each of the labels, a particular function must be called with a particular parameter.
To do this, I'm using this code:
for link in list_of_links:
link_label = Label(self.video_window, text="Frame "+str(video_number), fg="blue", cursor="hand2")
link_label.pack()
link_label.place(x=xcod2, y=ycod2)
link_label.bind("<1>", lambda x: self.goto_video_link(link))
Currently, I'm creating 10 labels. The problem is that on clicking any of the ten labels, the goto_video_link function seems to only use the 10th link.
If I click on the 5th label, I want it to use the 5th link.
How do I go about this?