[Python-bugs-list] [ python-Bugs-457487 ] Itemconfigure for Listbox

noreply@sourceforge.net noreply@sourceforge.net
Fri, 31 Aug 2001 22:10:14 -0700


Bugs item #457487, was opened at 2001-08-31 22:10
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=457487&group_id=5470

Category: Tkinter
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Itemconfigure for Listbox

Initial Comment:
The Tkinter included with version 2.1.1 does not include support for the Tk function itemconfigure 
for Listbox's.  This functionality is very useful for changing the appearance of individual entries in a 
Listbox (e.g. their colors).  This functionality is easily implemented by adding the following method 
to the Listbox class definition in Tkinter

    def itemconfigure(self, index, cnf=None, **kw):
        """Configure resources of an item .

        The values for resources are specified as keyword
        arguments. To get an overview about
        the allowed keyword arguments call the method without arguments.
        """
        if cnf is None and not kw:
            cnf = {}
            for x in self.tk.split(
                self.tk.call(self._w,
                         'itemconfigure', index)):
                cnf[x[0][1:]] = (x[0][1:],) + x[1:]
            return cnf
        if type(cnf) == StringType and not kw:
            x = self.tk.split(self.tk.call(
                self._w, 'itemconfigure', index, '-'+cnf))
            return (x[0][1:],) + x[1:]
        self.tk.call((self._w, 'itemconfigure', index) +
                 self._options(cnf, kw))
    itemconfig = itemconfigure

-----------
The code works, and I use it routinely in an augmented version of Tkinter.  It would be nice to 
eventually have it in the standard version.

thanks for everything.
Mike.

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

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