I have a list called 'optionlist' which may change length from day to day, but I want a tkinter dropdown box to be able to select something from it.
Here's an example of how to define a tkinter optionmenu:
opt1 = OptionMenu(root, var1, 'A', 'B', 'C')
A, B, and C are the options you can select. The problem presented here is that while the OptionMenu is flexible and allows as many options as you want, you have to know exactly how many you want when you write the code. This isn't a list or a tuple being passed.
I'm wondering if anyone knows any kung-fu for making this so I don't have to do:
if len(optionlist) == 1:
opt1 = OptionMenu(root, var1, optionlist[0])
if len(optionlist) == 2:
opt1 = OptionMenu(root, var1, optionlist[0], optionlist[1])
etc, etc, etc
I know you can define a list like this:
elements = [client.get('element') for client in clientlist]
I'm hoping something similar can be done when passing to methods as well.