Skip to content

Commit 77c674b

Browse files
committed
small rewording/reorganization of architecture and modules sections
1 parent 35521e8 commit 77c674b

File tree

1 file changed

+39
-45
lines changed

1 file changed

+39
-45
lines changed

Doc/library/tkinter.rst

Lines changed: 39 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
The :mod:`tkinter` package ("Tk interface") is the standard Python interface to
1414
the Tcl/Tk GUI toolkit. Tcl/Tk and :mod:`tkinter` are available on most Unix
15-
platforms, as well as on Windows systems.
15+
platforms (including macOS), as well as on Windows systems.
1616

1717
Running ``python -m tkinter`` from the command line should open a window
1818
demonstrating a simple Tk interface, letting you know that :mod:`tkinter` is
@@ -24,68 +24,62 @@ without thread support. The official Python binary release bundles Tcl/Tk 8.6
2424
threaded. See the source code for the :mode:`_tkinter` module
2525
for more information about supported versions.
2626

27-
Tkinter is not a thin wrapper, it adds a fair amount of own logic to
28-
make the experience more pythonic. This documentation will concentrate on this
29-
added and changed logic and refer to the official Tcl/Tk documentation for
30-
details that are unchanged.
27+
Tkinter is not a thin wrapper, but adds a fair amount of its own logic to
28+
make the experience more pythonic. This documentation will concentrate on these
29+
additions and changes, and refer to the official Tcl/Tk documentation for
30+
descriptions of underlying features.
3131

3232

3333
Architecture
3434
------------
3535

36-
Unlike most other GUI toolkits, Tcl/Tk is not a monolithic product providing a
37-
consolidated API. Instead, it's a bundle of libraries, each with its
38-
distinct functionality and separate documentation.
36+
Tkinter provides a unified interface to several separate and distinct libraries.
3937

4038
Tcl
41-
Tcl is a dynamic interpreted programming language. Though it can be used
42-
as a general-purpose programming language, it's primary developed to be and
43-
used as an embedded scripting engine for applications (same as Lua) and as
44-
an interface to the Tk toolkit. The Tcl engine library has a C interface to
45-
create and operate interpreter instances, run Tcl commands and scripts with
46-
them and add custom commands that can be implemented in either Tcl or C.
47-
It also implements a per-thread event queue (see `Threading model`_ for
48-
details).
49-
Each :class:`Tk` object embeds its own interpreter instance.
50-
Though :mod:`_tkinter` allows to execute entire Tcl scripts, the Python
51-
bindings typically only run single commands.
39+
Like Python, Tcl is a dynamic interpreted programming language. It is most
40+
commonly used by C applications to embed a scripting language, or as an
41+
interface to the Tk toolkit. The Tcl library has a C interface to
42+
create and manage one or more instances of a Tcl interpreter, run Tcl
43+
commands and scripts in those instances, and add custom commands
44+
implemented in either Tcl or C. Each interpreter instance also provides
45+
an event queue, used for I/O, timers, and by modules.
5246

5347
Tk
54-
Tk is a Tcl module implemented in C that adds custom commands to create and
55-
manipulate GUI widgets. The interpreter's event queue is used to generate
56-
and process events for all widgets created by it.
57-
Tcl can be used without Tk (and Tk needs to be explicitly loaded to make it
58-
available; :mod:`tkinter` does this automatically), though they are
59-
typically provided together, "Tcl/Tk" being the name for the bundle.
60-
Tk also implements the Themed Tk (Ttk) family of widgets, though `tkinter`
61-
provides Python bindings for them in a separate module, :mod:`tkinter.ttk`.
62-
Tk has its own C interface that duplicates the custom Tcl commands though
63-
`tkinter` mostly uses the latter.
48+
Tk is a module that can be loaded into a Tcl interpreter instance. It adds
49+
Tcl commands (implemented in C) to create and manipulate GUI widgets. Each
50+
:class:`Tk` object embeds its own Tcl interpreter instance with Tk loaded into
51+
it. Tk's widgets are very customizable, though at the cost of a dated appearance.
52+
Tk uses the interpreter's event queue to generate and process GUI events. Note
53+
that unlike some GUI libraries, each interpreter uses only a single thread,
54+
which has implications for :mod:`tkinter` users (see `Threading model`_).
55+
56+
Ttk
57+
Themed Tk (Ttk) is a newer family of Tk widgets that provide a much better
58+
appearance on different platforms than many of the classic Tk widgets.
59+
Ttk is distributed as part of Tk, starting with Tk version 8.5. Python
60+
bindings are provided in a separate module, :mod:`tkinter.ttk`.
6461

6562
Tix
66-
`Tix`<https://core.tcl.tk/jenglish/gutter/packages/tix.html>_ is a
67-
third-party Tcl module, an addon for Tk that adds several new widgets.
68-
`tkinter.tix` provides bindings for it, and official Python binary releases
69-
come with it bundled. It's deprecated in favor of Ttk.
63+
`Tix`<https://core.tcl.tk/jenglish/gutter/packages/tix.html>_ is an older
64+
third-party Tcl module, adding several new widgets to Tk. Python bindings
65+
are found in :mod:`tkinter.tix`. It has been deprecated in favor of Ttk.
7066

7167

7268
Tkinter Modules
7369
^^^^^^^^^^^^^^^
7470

75-
:mod:`tkinter` has the core functionality and the bindings for regular Tk
76-
widgets. Unless you're using the additional widgets, this will be all
77-
that you really need.
71+
Most applications will directly use the features provided by :mod:`tkinter`.
72+
Unless compatibility with very old versions of Tcl/Tk is required, Ttk widgets
73+
found in :mod:`tkinter.ttk` should also be favoured over their classic Tk
74+
counterparts.
7875

79-
:mod:`tkinter.ttk` and :mod:`tkinter.tix` have classes for extra
80-
widgets from those families. Ttk is intended to be the new standard widget
81-
set with a more modern look, but as of this writing, it doesn't yet have
82-
replacements for all the classical widgets.
76+
The :mod:`_tkinter` module provides low-level access to Tcl interpreters in Python,
77+
using the C interface to the Tcl library. It should rarely be used directly by
78+
application programmers. It may be needed to access features in very new versions
79+
of Tcl/Tk without an existing Python binding, though this reduces compatibility.
80+
It is usually a shared library (or DLL) but may be statically linked with the
81+
Python interpreter.
8382

84-
The core Tcl/Tk interface is located in a C module named :mod:`_tkinter`.
85-
This module directly interfaces with Tcl/Tk via their C interfaces and
86-
shouldn't be used directly by application programmers save for a few functions.
87-
It is usually a shared library (or DLL), but might in some cases be statically
88-
linked with the Python interpreter.
8983

9084

9185
Threading model

0 commit comments

Comments
 (0)