gpt4 book ai didi

python - 使用 tix、Tkinter 从 ComboBox 获取值

转载 作者:太空宇宙 更新时间:2023-11-03 17:53:43 25 4
gpt4 key购买 nike

我使用 Tkinter 包生成了 GUI。它有一些我用这些命令创建的条目

self.tent = Entry(self.side_options_frame)
self.tent.pack(padx=5, pady=6)

然后,我决定添加 ComboBox,并且我不想使用 ttk 包,所以我用这些命令创建了 ComboBox

from Tix import Tk, Control, ComboBox

self.tent = ComboBox(self.side_options_frame, label=' ',editable = True)
for temp in ('sim_trainer', 'sim_trainer:49916'):
self.tent.insert(END,temp)
self.tent.pack(padx=5, pady=6)

问题是,在我可以使用“self.tent.get()”获取条目之前,但现在我收到错误:

Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1470, in __call__
return self.func(*args)
File "C:\Users\Administrator\PycharmProjects\SSPFAT\SSPANIMATE\XMLGEN.py", line 318, in cancelButtonClick
self.inputset = [self.pipent.get(),self.hosent.get(),self.tent.get(),self.lent.get(),self.pent.get()]
File "C:\Python27\lib\lib-tk\Tix.py", line 341, in __getattr__
raise AttributeError, name
AttributeError: get

您能否告诉我如何从组合框中获取该条目?

最佳答案

使用self.tent['selection']代替self.tent.get()

关于python - 使用 tix、Tkinter 从 ComboBox 获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28787567/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com