ListBoxes [Tk]

Tom Jones (tom@cs.su.oz.au)
8 Feb 1995 14:23:47 +1100

My only documentation is the "Tkinter Life Preserver",
so be gentle.

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.

MyLB.get(MyLB.curselection()[0]) works correctly, ie
it returns the text of the currently selected line, so
it would make sense to me to be able to also say

MyNormalList[MyLB.curselection()[0]] = AdjustedValue

Can somebody explain why the first element of the tuple,
which looks like an index (ie an int) to me, is in fact a
string?

(ie, I can do what I want with atoi, but I can't see why
the index would be type string in the first place)

thankyou,

tom

---------------------------------------------------------------
Thomas J. Jones | PHONE : +61 2 351-3503 | FAX: +61 2 351-3838
Basser Department of Computer Science, Sydney University
We have tamed lightning and used it to teach sand to think.
---------------------------------------------------------------