0

I'm just learning Tkinter and have gone through numerous examples of setting up a combo box with predefined values, but I keep getting an error when I try to run it.

combo['Values'] = ("Private", "Commercial", "ATP") TypeError: 'NoneType' object does not support item assignment

Here is my code:

from tkinter import *
from tkinter import ttk

root = Tk()
root.title("Title Here")
root.geometry("250x300")
frame = ttk.Frame(root)

labeltext = StringVar()
labeltext.set("Click the OK button!!") # use the .set option to set the text value

checkboxvar = StringVar()
radiovar = StringVar()
entryVar = StringVar()
comboVar = StringVar()




def changetext():
    labeltext.set("thanks")
    print("OK button clicked")
    return


frame.grid(column=0, row=0, sticky = (N,S,E,W))
ttk.Label(frame, textvariable = labeltext, foreground="red").grid(column=1, row=1, sticky = W)


button1 = ttk.Button(frame, text="OK", default="active", command=changetext).grid(column=2, row=1, sticky = W)

checkbox = ttk.Checkbutton(frame, text="check me", variable = checkboxvar).grid(column=1, row = 3, sticky=W)

rbOne = ttk.Radiobutton(frame, text="One", variable=radiovar, value = "1").grid(column=1, row = 4, sticky = W)
rbTwo = ttk.Radiobutton(frame, text="Two", variable=radiovar, value = "2").grid(column=1, row = 5, sticky = W)
rbThree = ttk.Radiobutton(frame, text="Three", variable=radiovar, value = "3").grid(column=1, row = 6, sticky = W)

entry = ttk.Entry(frame, textvariable=entryVar).grid(column=1, row =7, sticky=W)


combo = ttk.Combobox(frame, textvariable=comboVar).grid(column=1, row =2, sticky=W)
combo['Values'] = ("Private", "Commercial", "ATP")


root.mainloop()
Seanmc2
  • 67
  • 1
  • 6
  • While not an exact duplicate, the root cause is the same: http://stackoverflow.com/q/1101750/7432 – Bryan Oakley Oct 27 '17 at 18:16
  • 1
    Thanks. Splitting the lines did the trick. Doing the object instantiation and the grid() assignment on two different lines solved my problem – Seanmc2 Oct 27 '17 at 18:31

0 Answers0