I tried updating the value of an OptionMenu in Tkinter but was unable to do so.
I updated the value of the (text)variable passed to the OptionMenu but that doesn't directly update it without hovering over it (or after a while). I even tried passing different configs (like text, value, ...) but those parameters either didn't exist or didn't directly update the value.
Program Code:
self.aPLabel = Label(self, text="Action to be performed", anchor='w')
self.aPLabel.grid(row=7, column=0, sticky=W)
self.aPVar = StringVar(self, "Play Buzzer")
self.aPBox = OptionMenu(self, self.aPVar, "Exit on done", "Play Buzzer", "Execute script")
self.aPBox.grid(row=7, column=1, sticky=W+E)
tmp=None
def callback(*args):
if self.aPVar.get()=="Execute script":
filename = askopenfilename(filetypes=[("Python Script (*.py)", ".py")])
if filename:
self.aPVar.set(f"Execute script: {filename}")
self.aPBox.configure()
tmp = self.aPVar.get()
else:
pass
self.aPVar.trace("w", callback)