<p>上面的链接有助于我们朝着正确的方向前进,我找到了解决办法。它要求我转换成一个网格几何布局,而不是一个包几何布局,以获得更多的功能和模块选择和返回文本条目。在选择一个列表项并在文本字段框中返回它时,需要分离事件绑定。再次,确认Sqlite数据库连接不是Rolf上面所述的此功能所必需的。在</p>
<pre><code>#Bind listbox selection into entry field
def get_list(event):
index = listbox1.curselection()[0]
seltext = listbox1.get(index)
enter1.delete(0, 50)
enter1.insert(0, seltext)
#Bind entry text into listbox
def set_list(event):
try:
index = listbox1.curselection()[0]
listbox1.delete(index)
except IndexError:
index = tk.END
listbox1.insert(index, enter1.get())
listbox1 = tk.Listbox(root, width=50, height=6)
listbox1.grid(row=0, column=0)
enter1 = tk.Entry(root, textvariable=source, width=50)
enter1.insert(0, 'Click on Fetch Button, then select item in the listbox')
enter1.grid(row=1, column=0)
enter1.bind('<Return>', set_list)
enter1.bind('<Double-1>', set_list)
listbox1.bind('<ButtonRelease-1>', get_list)
</code></pre>
<p>这个资源链接<a href="https://www.daniweb.com/programming/software-development/code/216827/working-with-a-tkinter-listbox-python" rel="nofollow">here</a>在某种程度上是我想要实现的一个很好的例子(除了使用Sqlite db connection命令)。在</p>