[Pythonmac-SIG] Question about Tkinter listbox
Jon Moody
jbmoody@oakland.edu
Thu, 31 May 2001 16:15:38 -0400
On Wed, May 30, 2001 at 09:27:51PM -0700, Josh English wrote:
> class window(Frame):
> def sendname(self):
> index = namelist.curselection() # Fails here
> print index # for testing
> label = namelist.get(index) # Fails here
> print label # for testing
The curselection() method returns a list of indices as strings; if
selectmode==SINGLE, it will return a list of 1 index as a string; to
use the index you have to convert it to an int:
label = namelist.get( map(int, index)[0] )
If that doesn't help, the traceback may provide more clues about
what's wrong.
--
Jon