summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-11-08 16:25:58 (GMT)
committerGitHub <noreply@github.com>2023-11-08 16:25:58 (GMT)
commit005d1e8fc81539c60c6b21ebba34de3edd5bb232 (patch)
tree345af36b78f7a6702223019f4c9e505ee466ab02 /Doc
parent74b868f636a8af9e5540e3315de666500147d47a (diff)
downloadcpython-005d1e8fc81539c60c6b21ebba34de3edd5bb232.zip
cpython-005d1e8fc81539c60c6b21ebba34de3edd5bb232.tar.gz
cpython-005d1e8fc81539c60c6b21ebba34de3edd5bb232.tar.bz2
gh-68166: Tkinter: Add tests and examples for element_create() (GH-111453)
* Remove mention of "vsapi" element type from the documentation. * Add tests for element_create() and other ttk.Style methods. * Add examples for element_create() in the documentation.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/tkinter.ttk.rst18
1 files changed, 16 insertions, 2 deletions
diff --git a/Doc/library/tkinter.ttk.rst b/Doc/library/tkinter.ttk.rst
index dc31a1a..5fab145 100644
--- a/Doc/library/tkinter.ttk.rst
+++ b/Doc/library/tkinter.ttk.rst
@@ -1391,8 +1391,7 @@ option. If you don't know the class name of a widget, use the method
.. method:: element_create(elementname, etype, *args, **kw)
Create a new element in the current theme, of the given *etype* which is
- 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.
+ expected to be either "image" or "from".
If "image" is used, *args* should contain the default image name followed
by statespec/value pairs (this is the imagespec), and *kw* may have the
@@ -1418,6 +1417,16 @@ option. If you don't know the class name of a widget, use the method
Specifies a minimum width for the element. If less than zero, the
base image's width is used as a default.
+ Example::
+
+ img1 = tkinter.PhotoImage(master=root, file='button.png')
+ img1 = tkinter.PhotoImage(master=root, file='button-pressed.png')
+ img1 = tkinter.PhotoImage(master=root, file='button-active.png')
+ style = ttk.Style(root)
+ style.element_create('Button.button', 'image',
+ img1, ('pressed', img2), ('active', img3),
+ border=(2, 4), sticky='we')
+
If "from" is used as the value of *etype*,
:meth:`element_create` will clone an existing
element. *args* is expected to contain a themename, from which
@@ -1425,6 +1434,11 @@ option. If you don't know the class name of a widget, use the method
If this element to clone from is not specified, an empty element will
be used. *kw* is discarded.
+ Example::
+
+ style = ttk.Style(root)
+ style.element_create('plain.background', 'from', 'default')
+
.. method:: element_names()