I am pretty new to Python as well as coding in general.
I've got 42 Labels (Strings) stored in a list. My aim is to: for each of the 42 labels, create a Tkinter Label displaying the String and a Dropdown List (Tkinter Optionmenu).
Two problems occur:
- I get an index error for the list of variables (for the optionmenus), here is the output of my Console:
varDd[i] = StringVar(root) IndexError: list assignment index out of range
- The Canvas is Scrollable as I intended, but the content doesn't scroll with it
My complete Code: https://codepaste.net/6jkuza
The essential part:
def createDdList():
del labelsDd[:]
del listsDd[:]
if len(labels) > 1:
varDd = [len(labels)]
for i,label in enumerate(labels):
# Erstelle Labels mit den Markerlabels im scrollbaren Canvas
labelsDd.append(Label(contentCanvas,text=label))
labelsDd[i].pack()
# Erstelle die Dropdown Listen im scrollbaren Canvas
varDd[i] = StringVar(root)
listsDd.append(OptionMenu(canvas,varDd[i],*labels))
listsDd[i].place(x=70,y=10+(30*i))
contentCanvas = Frame(canvas,bg='#FFFFFF')
canvas.create_window((0,375),window=contentCanvas)