你能从列表框中得到刷新的选择吗?

2024-10-01 07:34:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我想知道这是否可能。假设我有一个包含三项的列表框L1。如果我通过单击选择项目1,我想使L1.curselection()成为('0',),然后如果我选择项目3(不按住control或shift),我想现在更新L1.curselection(),这样我就得到了('2',)的输出。你知道吗

Tkinter中的listbox小部件是否可以实现这一点。我对curselection()的理解正确吗?你知道吗

我正在尝试构建类似文件查看器的东西。你知道吗


Tags: 文件项目l1shifttkintercontrollistbox列表框
1条回答
网友
1楼 · 发布于 2024-10-01 07:34:43

Is this possible with listbox widget in Tkinter

是的

Is my understanding of curselection() correct?

是的,可能吧


如果我没听错的话,这就是它的工作原理。引用http://effbot.org/tkinterbook/listbox.htm#Tkinter.Listbox.curselection-method

curselection()

Gets a list of the currently selected alternatives. The list contains the indexes of the selected alternatives (beginning with 0 for the first alternative in the list). In most Python versions, the list contains strings instead of integers. Since this may change in future versions, you should make sure your code can handle either case. See the patterns section for a suggested solution.

相关问题 更多 >