Nic*_*ick 2 python tkinter ttk python-3.x
我需要将值添加到 ttk.combobox 而不重新加载整个内容。向 GUI 添加值时,不应重新加载 GUI 上的当前选择。
我需要这样的东西:
for string in listofstrings:
if string not in self.combobox1['values']:
self.combobox1['values'].append(string)
Run Code Online (Sandbox Code Playgroud)
当我像这样尝试时,出现此错误:
AttributeError: 'tuple' 对象没有属性 'append'
(正如预期的那样)。
在此先感谢您的帮助。
怎么样:
if string not in self.combobox1['values']:
self.combobox1['values'] = (*self.combobox1['values'], string)
Run Code Online (Sandbox Code Playgroud)
或者:
if string not in self.combobox1['values']:
self.combobox1['values'] += (string,)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5895 次 |
| 最近记录: |