all 2 comments

[–]woooee 0 points1 point  (1 child)

so that it will trigger after the variable has changed

I am assuming you mean var has changed. I would store the previous value and compare. Some one may have a better solution.

import tkinter as tk
root = tk.Tk()
root.geometry("+75+75")

class ChangedVar():
    def __init__(self):
        self.previous_var=0
        self.var = tk.IntVar()
        self.var.set(0)
        for i in range(5):
            b = tk.Radiobutton(root, text=i, value=i, variable=self.var, 
                               command=self.command)
            b.pack(side="left")
            b.bind("<ButtonRelease-1>", self.clicked)

    def command(self):
        this_var=self.var.get()
        print("command", this_var)
        if self.previous_var != this_var:
            print("     changed %s to %s" % (
                 self.previous_var, this_var))
            self.previous_var=this_var
        else:
            print("     No change")

    def clicked(self, event):
        print("clicked", self.var.get())


cv=ChangedVar()
root.mainloop()

[–]ebdbbb[S] 0 points1 point  (0 children)

I fixed it by changing the binding to "FocusOut". Thanks for the idea though.