0

I have this list that builds a form, the problem is that each value from the list as a button and no matter what option i click it always assume the last value.

I need that the var specvar assume the right value and not the last one for all options.

thislist = ["opt1", "opt2", "opt3", "opt4", "opt5", "opt6","opt7"]
coll=int(0)
specvar=int(1)

for x in thislist:
    ttk.Button(frmbtn, width="10", text=x ,command=lambda: specs(specvar)).grid(column=coll, row=0, padx=10, pady=10)
    lbl = Label(frmbtn, text="Response / OBS:").grid(column=coll, row=1, padx=10, pady=10)
    kiblogbn = ScrolledText(frmbtn, width=25, height=20)
    kiblogbn.grid(column=coll, row=2, padx=10, pady=10, ipady=25)
    ttk.Button(frmbtn, width="5", text="OK", image=photoOK).grid(column=coll, row=3, padx=1, pady=1)
    ttk.Button(frmbtn, width="5", text="Not Ok", image=photoNot).grid(column=coll, row=4, padx=1, pady=1)
    coll += 1
    specvar += 1
ric
  • 1
  • 3
  • thanks got it. ttk.Button(frmbtn, width="10", text=x ,command=lambda specvar=specvar: specs(specvar)).grid(column=coll, row=0, padx=10, pady=10) – ric Jun 18 '21 at 10:07

0 Answers0