summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2001-10-01 10:09:31 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2001-10-01 10:09:31 (GMT)
commit2fa69d798498eb9d716e3d8e926745e5c1519727 (patch)
tree3775f338bbb9b94fe47e2e48723aa56f5c5d1797
parent0daad598d0947395248f087c2aa347083f440e36 (diff)
downloadcpython-2fa69d798498eb9d716e3d8e926745e5c1519727.zip
cpython-2fa69d798498eb9d716e3d8e926745e5c1519727.tar.gz
cpython-2fa69d798498eb9d716e3d8e926745e5c1519727.tar.bz2
Patch #426880: Implement Listbox itemcget and itemconfigure.
-rw-r--r--Lib/lib-tk/Tkinter.py25
-rw-r--r--Misc/NEWS2
2 files changed, 27 insertions, 0 deletions
diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py
index 2b04ee0..e72dbe5 100644
--- a/Lib/lib-tk/Tkinter.py
+++ b/Lib/lib-tk/Tkinter.py
@@ -2299,6 +2299,31 @@ class Listbox(Widget):
i = self.tk.call(self._w, 'index', index)
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."""
self.tk.call((self._w, 'insert', index) + elements)
diff --git a/Misc/NEWS b/Misc/NEWS
index b7ccc86..d4daf27 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -15,6 +15,8 @@ Library
- quopri's encode and decode methods take an optional header parameter,
which indicates whether output is intended for the header 'Q' encoding.
+- Tkinter.Listbox now exposes itemcget and itemconfigure.
+
Tools
Build