Name
curselection
Synopsis
L
.curselection( )
Returns a sequence of zero or more indices, from 0
upwards, of selected items. Depending on the underlying release of
Tk, curselection
may return string representations
of the integer indices, rather than the integers themselves. To
remove this uncertainty, you can use:
indices
= [ int(x
) forx
inL
.curselection( ) ]
However,
[
L
.get(
x
)
for
x
in
L
.curselection( )]
is
always the list of the zero or more text items that are selected, no
matter what form of indices curselection
returns.
Therefore, if you’re interested in selected text
items rather than selected indices, the uncertainty may not be an
issue.
Get Python in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.