Re: ListBoxes [Tk]

Guido.van.Rossum@cwi.nl
Wed, 08 Feb 1995 15:17:05 +0100

> The Listbox class has a useful little method
> curselection, which behaves much as expected, but
> returns a tuple of some sort, the first element
> of which is the index of the current selected line
> in the list-box. (ie, MyLB.curselection()[0])
>
> Now I want to use this index to update a list of my own
> (just an everyday plain list).
>
> However it turns out that the element MyLB.curselection()[0]
> is a *string*, and I need to atoi it to be able to use it
> on my list??? This seems very odd.

The reason is that Tk returns everything in string form. The Python
interface usually tries to hide this by converting strings to numbers
where it knows that a particular function result is always a number,
but in this case we forgot to do that. I suppose this should be fixed
in the next release.

--Guido van Rossum, CWI, Amsterdam <mailto:Guido.van.Rossum@cwi.nl>
<http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>