[Python-checkins] CVS: python/dist/src/Lib/lib-tk Tkinter.py,1.157,1.158

Martin v. L?wis loewis@users.sourceforge.net
Mon, 01 Oct 2001 03:09:33 -0700


Update of /cvsroot/python/python/dist/src/Lib/lib-tk
In directory usw-pr-cvs1:/tmp/cvs-serv24727/Lib/lib-tk

Modified Files:
	Tkinter.py 
Log Message:
Patch #426880: Implement Listbox itemcget and itemconfigure.


Index: Tkinter.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tkinter.py,v
retrieving revision 1.157
retrieving revision 1.158
diff -C2 -d -r1.157 -r1.158
*** Tkinter.py	2001/09/05 19:29:56	1.157
--- Tkinter.py	2001/10/01 10:09:31	1.158
***************
*** 2300,2303 ****
--- 2300,2328 ----
          if i == 'none': return None
          return getint(i)
+     def itemcget(self, index, option):
+         """Return the resource value for an ITEM and an OPTION."""
+         return self.tk.call(
+             (self._w, 'itemcget') + (index, '-'+option))
+     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.
+         Valid resource names: background, foreground,
+         selectbackground, selectforeground."""
+         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
      def insert(self, index, *elements):
          """Insert ELEMENTS at INDEX."""