The following code creates an OptionMenu with two options: "A" or "B":
from Tkinter import *
root = Tk()
clicked = StringVar(root)
clicked.set("Select")
def function(x):
if x == "A":
doSomething()
else:
donNothing()
drop = OptionMenu(root, clicked, "A", "B", command=function)
drop.pack()
root.mainloop()
In this code, it assumes that the data table has only columns A & B. However, the data tables I import all have a different number of columns (e.g. one dataset may have columns A, B, C, D, E whereas another dataset may have columns A, B, C).
How can I change the option menu's number of drop down options depending on the number of columns my data has (e.g. if one dataset has 3 columns, the option menu will have 3 options whereas if another dataset has 5 columns, the option menu will have 5 options)?