โI want to populate the options menu in Tkinter with elements from different lists, how to do this? The code below treats the entire list as one element in the menu. I tried to use the for operator to scroll through the list, but it gave me the valueโ a โseveral times.
from Tkinter import * def print_it(event): print var.get() root = Tk() var = StringVar() var.set("a") lst = ["a,b,c,d,e,f"] OptionMenu(root, var, lst, command=print_it).pack() root.mainloop()
I want to pass a variable to this function, but I get a syntax error for the second line:
def set_wkspc(event): x = var.get() if x = "Done": break else: arcpy.env.workspace = x print x
kflaw source share