#32 PmwScrolledListBox's getcurselection() produces tcl error

closed-out-of-date
nobody
None
5
2012-07-12
2008-09-06
Anonymous
No

Calling getcurselection on PmwScrolledListBox when nothing is selected gets this error:

File "C:\Python25\Lib\site-packages\Pmw\Pmw_1_3\lib\PmwScrolledListBox.py", line 129, in getcurselection
rtn.append(self._listbox.get(sel))
File "C:\Python25\lib\lib-tk\Tkinter.py", line 2499, in get
return self.tk.call(self._w, 'get', first)
TclError: bad listbox index "None": must be active, anchor, end, @x,y, or a number

This is fixed by changing the method to:

def getcurselection(self):
rtn = []
for sel in self.curselection():
if sel != "None":
rtn.append(self._listbox.get(sel))
return tuple(rtn)

Discussion

  • nanotube

    nanotube - 2009-07-07

    Hi
    Which version of python and Pmw does this happen on? I cannot reproduce using either python 2.5.2 or python 2.6.2. In my testing I see that getcurselection with nothing selected gets a "sel" that's an empty list returned from self.curselection(), the for loop thus doesn't do anything, and the return value is again an empty tuple...

     
  • Adrian

    Adrian - 2011-08-12

    I can't seem to be able to reproduce this error, either. Running Python 2.7.1 - please add more details if you've encountered this error.

     
  • Adrian

    Adrian - 2012-07-12
    • status: open --> closed-out-of-date
     
  • Adrian

    Adrian - 2012-07-12

    Bug can not be reproduced; this seems to be out of date.

     

Log in to post a comment.