Python 3.x Python3.x:TypeError:';StringVar';对象不可编辑&;属性错误:';StringVar';对象没有属性';项目';

Python 3.x Python3.x:TypeError:';StringVar';对象不可编辑&;属性错误:';StringVar';对象没有属性';项目';,python-3.x,user-interface,tkinter,Python 3.x,User Interface,Tkinter,当我尝试这个的时候 archivist_dates=[ "Thur,19th of October", "Fri,20th of October", "Sat,21th of October", "Sun,22th of October", "Mon,23th of October", "Tue,24th of October", "Wed,25th of October", "Latest"]# the list of dates

当我尝试这个的时候

archivist_dates=[
    "Thur,19th of October",
    "Fri,20th of October",
    "Sat,21th of October",
    "Sun,22th of October",
    "Mon,23th of October",
    "Tue,24th of October",
    "Wed,25th of October",
    "Latest"]# the list of dates to be selected by the users



variable=StringVar()
variable.set(archivist_dates[0])

list_menu=OptionMenu(archivist_gui,variable,*archivist_dates)
list_menu.grid(row=2,column=2)


archivist_buttons=Frame(archivist_gui)
extract_button=Radiobutton(archivist_buttons,variable,text='Extract news 
from archive', value=1, font=('Times',24),command=extracts)

display_button=Radiobutton(archivist_buttons,variable,text='Display news 
extracted',value=2,font=('Times',24),command=htmlgenerator)

archive_button=Radiobutton(archivist_buttons,variable,text='Archive the 
latest news',value=3,font=('Tikmes',24),command=download)
出现如下错误声明:

_cnfmerge:由于“StringVar”对象不可回溯而导致的回退(最近一次调用last):文件 “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/init.py”, 第103行,in_cnfmerge cnf.update(c)TypeError:“StringVar”对象不可编辑

在处理上述异常期间,发生了另一个异常:

回溯(最近一次调用上次):文件 “/Volumes/study/en01/ifb104/ass2/internetrachive/news\u archivist.py”, 第798行,输入 提取按钮=单选按钮(归档按钮、变量、文本=”提取 存档新闻',值=1,字体=('Times',24),命令=extracts)
文件 “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/init.py”, 第2978行,在init 控件。init(self,master,'radiobutton',cnf,kw)文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/init.py”, 第2284行,在init cnf=_cnfmerge((cnf,kw))文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/init.py”, 第106行,in_cnfmerge 对于c.items()中的k,v:AttributeError:'StringVar'对象没有属性'items'

有人能解释一下错误并帮我修复吗?

问题在这里:

extract_button=Radiobutton(archivist_buttons,variable,text='Extract news from archive', value=1, font=('Times',24),command=extracts)
您分配的
变量
不正确,
单选按钮
正在查找不存在的
变量['items']
,因为
StringVar()
没有名为
'items'
的属性

相反,您应该将
StringVar()
指定为
variable=variable
。这意味着整个通话将是:

extract_button=Radiobutton(archivist_buttons,variable=variable,text='Extract news from archive', value=1, font=('Times',24),command=extracts)