[Python-checkins] r65028 - in sandbox/trunk/ttk-gsoc: Doc/library/ttk.rst src/2.x/ttk.py src/3.x/ttk.py
guilherme.polo
python-checkins at python.org
Wed Jul 16 20:57:20 CEST 2008
Author: guilherme.polo
Date: Wed Jul 16 20:57:20 2008
New Revision: 65028
Log:
theme_use will return the current theme in use if nothing is passed to it now;
Added support for some new commands available since Tk 8.6a1;
Version is 0.1.4 now;
Modified:
sandbox/trunk/ttk-gsoc/Doc/library/ttk.rst
sandbox/trunk/ttk-gsoc/src/2.x/ttk.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 Wed Jul 16 20:57:20 2008
@@ -936,6 +936,32 @@
The tree column has ID #0.
+ .. method:: identify_region(x, y)
+
+ Returns one of:
+
+ +-----------+--------------------------------------+
+ | region | meaning |
+ +===========+======================================+
+ | heading | Tree heading area. |
+ +-----------+--------------------------------------+
+ | separator | Space between two columns headings. |
+ +-----------+--------------------------------------+
+ | tree | The tree area. |
+ +-----------+--------------------------------------+
+ | cell | A data cell. |
+ +-----------+--------------------------------------+
+
+ Availability: Tk 8.6.
+
+
+ .. method:: identify_element(x, y)
+
+ Returns the element at position x, y.
+
+ Availability: Tk 8.6.
+
+
.. method:: index(item)
Returns the integer index of *item* within its parent's list of children.
@@ -1062,6 +1088,15 @@
returns a dictionary of the option settings for *tagname*.
+ .. method:: tag_has(tagname[, item])
+
+ If *item* is specified, returns 1 or 0 depending on whether the specified
+ *item* has the given *tagname*. Otherwise, returns a list of all items
+ which have the specified tag.
+
+ Availability: Tk 8.6
+
+
.. method:: xview(*args)
Query or modify horizontal position of the treeview.
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 Wed Jul 16 20:57:20 2008
@@ -12,7 +12,7 @@
of the widgets appearance lies at Themes.
"""
-__version__ = "0.1.3"
+__version__ = "0.1.4"
__author__ = "Guilherme Polo <ggpolo at gmail.com>"
@@ -344,7 +344,7 @@
val = _convert_stringval(val)
elif val and hasattr(val, '__len__'):
- if hasattr(val[0], 'typename') and val[0].typename == 'StateSpec':
+ if getattr(val[0], 'typename', None) == 'StateSpec':
val = _list_from_statespec(val)
else:
# converts a sequence that possibly has Tcl objects, or not,
@@ -510,8 +510,14 @@
return self.tk.call(self._name, "theme", "names")
- def theme_use(self, themename):
- """Sets the current theme to themename and refreshes all widgets."""
+ def theme_use(self, themename=None):
+ """If themename is None, returns the theme in use, otherwise set
+ the current theme to themename and refreshes all widgets."""
+ if themename is None:
+ # Starting on Tk 8.6, checking this global is no longer needed
+ # since it allows doing self.tk.call(self._name, "theme", "use")
+ return self.tk.eval("return $::ttk::currentTheme")
+
self.tk.call(self._name, "theme", "use", themename)
@@ -1248,6 +1254,25 @@
return self.identify("column", x, 0)
+ def identify_region(self, x, y):
+ """Returns one of:
+
+ heading: Tree heading area.
+ separator: Space between two columns headings;
+ tree: The tree area.
+ cell: A data cell.
+
+ * Availability: Tk 8.6"""
+ return self.identify("region", x, y)
+
+
+ def identify_element(self, x, y):
+ """Returns the element at position x, y.
+
+ * Availability: Tk 8.6"""
+ return self.identify("element", x, y)
+
+
def index(self, item):
"""Returns the integer index of item within its parent's list
of children."""
@@ -1388,6 +1413,13 @@
tagname)
+ def tag_has(self, tagname, item=None):
+ """If item is specified, returns 1 or 0 depending on whether the
+ specified item has the given tagname. Otherwise, returns a list of
+ all items which have the specified tag."""
+ return self.tk.call(self._w, "tag", "has", tagname, item)
+
+
def xview(self, *args):
"""Query or modify horizontal position of the treeview."""
return self.tk.call(self._w, "xview", *args)
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 Wed Jul 16 20:57:20 2008
@@ -12,7 +12,7 @@
of the widgets appearance lies at Themes.
"""
-__version__ = "0.1.3"
+__version__ = "0.1.4"
__author__ = "Guilherme Polo <ggpolo at gmail.com>"
@@ -344,7 +344,7 @@
val = _convert_stringval(val)
elif val and hasattr(val, '__len__'):
- if hasattr(val[0], 'typename') and val[0].typename == 'StateSpec':
+ if getattr(val[0], 'typename', None) == 'StateSpec':
val = _list_from_statespec(val)
else:
# converts a sequence that possibly has Tcl objects, or not,
@@ -510,8 +510,14 @@
return self.tk.call(self._name, "theme", "names")
- def theme_use(self, themename):
- """Sets the current theme to themename and refreshes all widgets."""
+ def theme_use(self, themename=None):
+ """If themename is None, returns the theme in use, otherwise set
+ the current theme to themename and refreshes all widgets."""
+ if themename is None:
+ # Starting on Tk 8.6, checking this global is no longer needed
+ # since it allows doing self.tk.call(self._name, "theme", "use")
+ return self.tk.eval("return $::ttk::currentTheme")
+
self.tk.call(self._name, "theme", "use", themename)
@@ -1248,6 +1254,25 @@
return self.identify("column", x, 0)
+ def identify_region(self, x, y):
+ """Returns one of:
+
+ heading: Tree heading area.
+ separator: Space between two columns headings;
+ tree: The tree area.
+ cell: A data cell.
+
+ * Availability: Tk 8.6"""
+ return self.identify("region", x, y)
+
+
+ def identify_element(self, x, y):
+ """Returns the element at position x, y.
+
+ * Availability: Tk 8.6"""
+ return self.identify("element", x, y)
+
+
def index(self, item):
"""Returns the integer index of item within its parent's list
of children."""
@@ -1388,6 +1413,13 @@
tagname)
+ def tag_has(self, tagname, item=None):
+ """If item is specified, returns 1 or 0 depending on whether the
+ specified item has the given tagname. Otherwise, returns a list of
+ all items which have the specified tag."""
+ return self.tk.call(self._w, "tag", "has", tagname, item)
+
+
def xview(self, *args):
"""Query or modify horizontal position of the treeview."""
return self.tk.call(self._w, "xview", *args)
More information about the Python-checkins
mailing list