I'm writing a simple gui to change the brightness of the monitor, however I'm having a problem.
def start_ui(self):
root = Tk()
root.wm_title("Set brightness")
col = 0
for k, v in self.monitors.iteritems():
print k
Scale(root, variable = DoubleVar(), command = lambda(r): self.change_brightness(k, r)).grid(row=0, column=col)
labelVar = StringVar()
label = Label(root, textvariable=labelVar).grid(row=1, column=col)
labelVar.set(k)
col += 1
root.mainloop()
This is where I start my UI, my self.monitors dictionary looks like this: {'LVDS1': '1.0', 'VGA1': '1.0'}.
The output of the loop is "LVDS1, VGA1" as expected, however, when I move the sliders and the callback is called, the last value of k is always passed, in this case "VGA1", no matter which slider I moved.
What could be causing this?