[Python-checkins] r63526 - 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
Thu May 22 00:25:12 CEST 2008
Author: guilherme.polo
Date: Thu May 22 00:25:11 2008
New Revision: 63526
Log:
Update Style.map and Style.layout documentation, example added for
the latter;
Corrected a typo in a docstring at ttk.py and fixed the example at
_format_mapdict's docstring.
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 Thu May 22 00:25:11 2008
@@ -1132,10 +1132,10 @@
style = ttk.Style()
style.map("C.TButton",
- foreground=[(('pressed', ), 'red'),
- (('active', ), 'blue')],
- background=[(('pressed', '!disabled'), 'black'),
- (('active', ), 'white')]
+ foreground=[(['pressed'], 'red'),
+ (['active'], 'blue')],
+ background=[(['pressed', '!disabled'], 'black'),
+ (['active'], 'white')]
)
colored_btn = ttk.Button(text="Test", style="C.TButton").pack()
@@ -1143,7 +1143,7 @@
root.mainloop()
- There are two things to note in this previous short example:
+ There is a thing to note in this previous short example:
* The order of the (state, value) sequences for an option does matter,
if you changed the order to [(('active', ), 'blue'), (('pressed', ),
@@ -1172,15 +1172,40 @@
return the layout specification for given style.
*layoutspec*, if specified, is expected to be a list, or some other
- sequence type, where each item should be a tuple and the first item is
- the layout name and the second item should have the format described
- described in `Layouts`_.
+ sequence type (excluding string), where each item should be a tuple and
+ the first item is the layout name and the second item should have the
+ format described described in `Layouts`_.
+
+ To understand the format, check this example below (it is not intended
+ to do anything useful)::
+
+ import ttk
+ import Tkinter
+
+ root = Tkinter.Tk()
+
+ style = ttk.Style()
+ style.layout("TMenubutton", [
+ ("Menubutton.background", None),
+ ("Menubutton.button", {"children":
+ [("Menubutton.focus", {"children":
+ [("Menubutton.padding", {"children":
+ [("Menubutton.label", {"side": "left", "expand": 1})]
+ })]
+ })]
+ }),
+ ])
+
+ mbtn = ttk.Menubutton(text='Text')
+ mbtn.pack()
+ root.mainloop()
.. method:: element_create(elementname, etype, *args, **kw)
Create a new element in the current theme of given *etype* which is
- expected to be either "image" or "from".
+ expected to be either "image", "from" or "vsapi". The latter is only
+ available in Tk 8.6a for Windows XP and Vista and is not described here.
If "image" is used, *args* should contain the default image name followed
by statespec/value pairs (this is the imagespec), *kw* may have the
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 Thu May 22 00:25:11 2008
@@ -79,7 +79,7 @@
"""Formats mapdict to pass it to tk.call.
E.g. (script=False):
- {'background': [(('active", ), 'white'), (('focus', ), 'blue')]} returns:
+ {'background': [(['active'], 'white'), (['focus'], 'blue')]} returns:
('-background', 'active white focus blue')"""
# if caller passes a Tcl script to tk.call, all the values need to
# be grouped into words (arguments to a command in Tcl dialect)
@@ -1171,7 +1171,7 @@
already exist in the tree. Otherwise, a new unique identifier
is generated."""
opts, values = _format_optdict(kw, ignore='values'), kw.get('values')
- # values may need special formatting if any value contain a space
+ # values may need special formatting if any value contains a space
if values:
opts += ("-values",
' '.join(('{%s}' if ' ' in v else '%s') % v for v in values))
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 Thu May 22 00:25:11 2008
@@ -79,7 +79,7 @@
"""Formats mapdict to pass it to tk.call.
E.g. (script=False):
- {'background': [(('active", ), 'white'), (('focus', ), 'blue')]} returns:
+ {'background': [(['active'], 'white'), (['focus'], 'blue')]} returns:
('-background', 'active white focus blue')"""
# if caller passes a Tcl script to tk.call, all the values need to
# be grouped into words (arguments to a command in Tcl dialect)
@@ -1171,7 +1171,7 @@
already exist in the tree. Otherwise, a new unique identifier
is generated."""
opts, values = _format_optdict(kw, ignore='values'), kw.get('values')
- # values may need special formatting if any value contain a space
+ # values may need special formatting if any value contains a space
if values:
opts += ("-values",
' '.join(('{%s}' if ' ' in v else '%s') % v for v in values))
More information about the Python-checkins
mailing list