[Python-checkins] r68989 - in sandbox/trunk/ttk-gsoc: Doc/library/ttk.rst src/2.x/test/test_treeview.py src/2.x/ttk.py src/3.x/test/test_treeview.py src/3.x/ttk.py

guilherme.polo python-checkins at python.org
Tue Jan 27 02:20:08 CET 2009


Author: guilherme.polo
Date: Tue Jan 27 02:20:08 2009
New Revision: 68989

Log:
Changed signature of Treeview.delete (to better), added tests for it and 
updated doc to match current code.


Modified:
   sandbox/trunk/ttk-gsoc/Doc/library/ttk.rst
   sandbox/trunk/ttk-gsoc/src/2.x/test/test_treeview.py
   sandbox/trunk/ttk-gsoc/src/2.x/ttk.py
   sandbox/trunk/ttk-gsoc/src/3.x/test/test_treeview.py
   sandbox/trunk/ttk-gsoc/src/3.x/ttk.py

Modified: sandbox/trunk/ttk-gsoc/Doc/library/ttk.rst
==============================================================================
--- sandbox/trunk/ttk-gsoc/Doc/library/ttk.rst	(original)
+++ sandbox/trunk/ttk-gsoc/Doc/library/ttk.rst	Tue Jan 27 02:20:08 2009
@@ -11,7 +11,7 @@
 The :mod:`ttk` module provides access to the Tk themed widget set, which
 has been introduced in Tk 8.5. If you do not have Python compiled against
 Tk 8.5 you may still use this module as long as you have Tile installed, but
-then you will miss some features of the new Tk, like anti-aliased font
+then you will miss some features provided by the new Tk, like anti-aliased font
 rendering under X11, window transparency (on X11 you will need a composition
 window manager) and others.
 
@@ -274,7 +274,7 @@
       which flags were changed. If *statespec* is not specified, returns
       the currently-enabled state flags.
 
-   Note that *statespec* is always expected to be a sequence.
+   *statespec* will usually be a list or a tuple.
 
 
 Combobox
@@ -890,7 +890,7 @@
 
       To configure the tree column, call this with column = "#0"
 
-   .. method:: delete(items)
+   .. method:: delete(*items)
 
       Delete all specified *items* and all their descendants.
 
@@ -1009,14 +1009,14 @@
       See `Item Options`_ for the list of available points.
 
 
-   .. method:: item(item, **kw)
+   .. method:: item(item[, option[, **kw]])
 
       Query or modify the options for the specified *item*.
 
-      If no options are specified, returns a dictionary of option/value pairs.
-      If a single option is specified with value None, returns the value of
-      that option. Otherwise, the item's options are updated with the specified
-      values.
+      If no options are given, a dict with options/values for the item is
+      returned.
+      If *option* is specified then the value for that option is returned.
+      Otherwise, sets the options to the corresponding values as given by *kw*.
 
 
    .. method:: move(item, parent, index)

Modified: sandbox/trunk/ttk-gsoc/src/2.x/test/test_treeview.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/2.x/test/test_treeview.py	(original)
+++ sandbox/trunk/ttk-gsoc/src/2.x/test/test_treeview.py	Tue Jan 27 02:20:08 2009
@@ -110,6 +110,14 @@
         self.failUnlessRaises(Tkinter.TclError,
             self.tv.reattach, item_id, '', 'end')
 
+        # test multiple item delete
+        item1 = self.tv.insert('', 'end')
+        item2 = self.tv.insert('', 'end')
+        self.failUnlessEqual(self.tv.get_children(), (item1, item2))
+
+        self.tv.delete(item1, item2)
+        self.failIf(self.tv.get_children())
+
 
     def test_detach_reattach(self):
         item_id = self.tv.insert('', 'end')

Modified: sandbox/trunk/ttk-gsoc/src/2.x/ttk.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/2.x/ttk.py	(original)
+++ sandbox/trunk/ttk-gsoc/src/2.x/ttk.py	Tue Jan 27 02:20:08 2009
@@ -1222,7 +1222,7 @@
         return _val_or_dict(kw, self.tk.call, self._w, "column", column)
 
 
-    def delete(self, items):
+    def delete(self, *items):
         """Delete all specified items and all their descendants. The root
         item may not be deleted."""
         self.tk.call(self._w, "delete", items)
@@ -1351,9 +1351,10 @@
     def item(self, item, option=None, **kw):
         """Query or modify the options for the specified item.
 
-        If kw is not given, returns a dict of item option values. If option
-        is specified then the value for that option is returned. Otherwise,
-        sets the options to the corresponding values."""
+        If no options are given, a dict with options/values for the item
+        is returned. If option is specified then the value for that option
+        is returned. Otherwise, sets the options to the corresponding
+        values as given by kw."""
         if option is not None:
             kw[option] = None
         return _val_or_dict(kw, self.tk.call, self._w, "item", item)

Modified: sandbox/trunk/ttk-gsoc/src/3.x/test/test_treeview.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/3.x/test/test_treeview.py	(original)
+++ sandbox/trunk/ttk-gsoc/src/3.x/test/test_treeview.py	Tue Jan 27 02:20:08 2009
@@ -110,6 +110,14 @@
         self.failUnlessRaises(tkinter.TclError,
             self.tv.reattach, item_id, '', 'end')
 
+        # test multiple item delete
+        item1 = self.tv.insert('', 'end')
+        item2 = self.tv.insert('', 'end')
+        self.failUnlessEqual(self.tv.get_children(), (item1, item2))
+
+        self.tv.delete(item1, item2)
+        self.failIf(self.tv.get_children())
+
 
     def test_detach_reattach(self):
         item_id = self.tv.insert('', 'end')

Modified: sandbox/trunk/ttk-gsoc/src/3.x/ttk.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/3.x/ttk.py	(original)
+++ sandbox/trunk/ttk-gsoc/src/3.x/ttk.py	Tue Jan 27 02:20:08 2009
@@ -1222,7 +1222,7 @@
         return _val_or_dict(kw, self.tk.call, self._w, "column", column)
 
 
-    def delete(self, items):
+    def delete(self, *items):
         """Delete all specified items and all their descendants. The root
         item may not be deleted."""
         self.tk.call(self._w, "delete", items)
@@ -1351,9 +1351,10 @@
     def item(self, item, option=None, **kw):
         """Query or modify the options for the specified item.
 
-        If kw is not given, returns a dict of item option values. If option
-        is specified then the value for that option is returned. Otherwise,
-        sets the options to the corresponding values."""
+        If no options are given, a dict with options/values for the item
+        is returned. If option is specified then the value for that option
+        is returned. Otherwise, sets the options to the corresponding
+        values as given by kw."""
         if option is not None:
             kw[option] = None
         return _val_or_dict(kw, self.tk.call, self._w, "item", item)


More information about the Python-checkins mailing list