[Python-bugs-list] [ python-Bugs-621511 ] Tix Checklist getselection getstatus bug

noreply@sourceforge.net noreply@sourceforge.net
Fri, 11 Oct 2002 13:10:58 -0700


Bugs item #621511, was opened at 2002-10-10 14:09
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=621511&group_id=5470

Category: Tkinter
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Kerry W. Clark (kerrywclark)
Assigned to: Nobody/Anonymous (nobody)
Summary: Tix Checklist getselection getstatus bug

Initial Comment:
The Tix Checklist widget commands getselection and
getstatus always return "none" instead of a list of
selected items.

When looking at the /Lib/lib-tk/Tix.py both these
routines are missing return statements:

    def getselection(self, mode='on'):
        '''Mode can be on, off, default'''
        self.tk.call(self._w, 'getselection', mode)

    def getstatus(self, entrypath):
        self.tk.call(self._w, 'getstatus', entrypath)


When return statements are added these commands work as
advertised:

    def getselection(self, mode='on'):
        '''Mode can be on, off, default'''
        return self.tk.call(self._w, 'getselection', mode)

    def getstatus(self, entrypath):
        return self.tk.call(self._w, 'getstatus',
entrypath)

This was seen in Python 2.2.1 but appears to be there
for earlier
releases as well. Is there a reason for this?



----------------------------------------------------------------------

>Comment By: Kerry W. Clark (kerrywclark)
Date: 2002-10-11 15:10

Message:
Logged In: YES 
user_id=626964

Forgot the case with no selection:

    def getselection(self, mode='on'):
        '''Mode can be on, off, default'''
        cnf = []
	x = self.tk.call(self._w,  'getselection', mode)
        if string.find (x, ' ') == -1:
           if len(x) > 0:
              cnf.append (x)
        else:
           cnf = list (self.tk.split(x))
        return cnf


----------------------------------------------------------------------

Comment By: Kerry W. Clark (kerrywclark)
Date: 2002-10-11 14:57

Message:
Logged In: YES 
user_id=626964

You are right. How would this look?

   def getselection(self, mode='on'):
        '''Mode can be on, off, default'''
        cnf = []
	x = self.tk.call(self._w,  'getselection', mode)
        if string.find (x, ' ') == -1:
           cnf.append (x)
        else:
           cnf = list (self.tk.split(x))
        return cnf


----------------------------------------------------------------------

Comment By: Internet Discovery (idiscovery)
Date: 2002-10-11 12:14

Message:
Logged In: YES 
user_id=33229

You're right - there should be values returned.

Ideally, getselection should return a Python list,
not just a Tcl string which is a list to Tcl.

Mike

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=621511&group_id=5470