20.1.5 How Tk and Tkinter are Related
Note: This was derived from a graphical image; the image will be used more directly in a subsequent version of this document.
From the top down:
- A Python application makes a Tkinter call.
- This call (say, for example, creating a button widget), is
implemented in the Tkinter module, which is written in
Python. This Python function will parse the commands and the
arguments and convert them into a form that makes them look as if they
had come from a Tk script instead of a Python script.
- These commands and their arguments will be passed to a C function
in the tkinter - note the lowercase - extension module.
- This C function is able to make calls into other C modules,
including the C functions that make up the Tk library. Tk is
implemented in C and some Tcl. The Tcl part of the Tk widgets is used
to bind certain default behaviors to widgets, and is executed once at
the point where the Python Tkinter module is
imported. (The user never sees this stage).
- The Tk part of the Tk Widgets implement the final mapping to ...
- the Xlib library to draw graphics on the screen.
See About this document... for information on suggesting changes.