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

Guido van Rossum gvanrossum@users.sourceforge.net
Sat, 01 Sep 2001 11:29:57 -0700


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

Modified Files:
	Tkinter.py 
Log Message:
Add Listbox.itemconfig[ure] call.  (A "recent" addition to Tk -- 8.0
doesn't have it.)  This is from SF bug #457487 by anonymous.


Index: Tkinter.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tkinter.py,v
retrieving revision 1.155
retrieving revision 1.156
diff -C2 -d -r1.155 -r1.156
*** Tkinter.py	2001/08/23 13:25:59	1.155
--- Tkinter.py	2001/09/01 18:29:55	1.156
***************
*** 4,10 ****
  control of widgets. Toplevel widgets are Tk and Toplevel. Other
  widgets are Frame, Label, Entry, Text, Canvas, Button, Radiobutton,
! Checkbutton, Scale, Listbox, Scrollbar, OptionMenu. Properties of the widgets are
! specified with keyword arguments.  Keyword arguments have the same
! name as the corresponding resource under Tk.
  
  Widgets are positioned with one of the geometry managers Place, Pack
--- 4,10 ----
  control of widgets. Toplevel widgets are Tk and Toplevel. Other
  widgets are Frame, Label, Entry, Text, Canvas, Button, Radiobutton,
! Checkbutton, Scale, Listbox, Scrollbar, OptionMenu. Properties of the
! widgets are specified with keyword arguments.  Keyword arguments have
! the same name as the corresponding resource under Tk.
  
  Widgets are positioned with one of the geometry managers Place, Pack
***************
*** 12,17 ****
  available in every Widget.
  
! Actions are bound to events by resources (e.g. keyword argument command) or
! with the method bind.
  
  Example (Hello, World):
--- 12,17 ----
  available in every Widget.
  
! Actions are bound to events by resources (e.g. keyword argument
! command) or with the method bind.
  
  Example (Hello, World):
***************
*** 2364,2367 ****
--- 2364,2388 ----
          """Shift the y-view according to NUMBER which is measured in "units" or "pages" (WHAT)."""
          self.tk.call(self._w, 'yview', 'scroll', number, what)
+     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, bg, foreground, fg,
+         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
  
  class Menu(Widget):