How to determine when OptionMenu or Checkbutton changes?

There are several controls in my tkinter application, and I would like to know when any changes occur so that I can update other parts of the application.

Is there anything I can do without writing an update function and ending at the end:

root.after(0, updaterfunction) 

This method has worked in the past, but I'm afraid it could be expensive if there are a lot of things to check.

Even if I used this method, can I save resources only by updating elements with changed variables? If so, share how, since I'm not sure how to detect specific changes outside the update function.

+3
source share
2 answers
+7

, OptionMenu

.

def OptionMenu_SelectionEvent(event): # I'm not sure on the arguments here, it works though
    ## do something
    pass

var = StringVar()
var.set("one")
options = ["one", "two", "three"]
OptionMenu(frame, var, *(options), command = OptionMenu_SelectionEvent).pack()
+1

All Articles