Most of the time, the Tkinter module is all you really
need, but a number of additional modules are available as well. The
Tk interface is located in a binary module named _tkinter.
This module contains the low-level interface to Tk, and should never
be used directly by application programmers. It is usually a shared
library (or DLL), but might in some cases be statically linked with
the Python interpreter.
In addition to the Tk interface module, Tkinter includes a
number of Python modules. The two most important modules are the
Tkinter module itself, and a module called
Tkconstants. The former automatically imports the latter, so
to use Tkinter, all you need to do is to import one module:
Or, more often:
class Tk( |
screenName=None, baseName=None, className='Tk', useTk=1) |
-
The Tk class is instantiated without arguments.
This creates a toplevel widget of Tk which usually is the main window
of an appliation. Each instance has its own associated Tcl interpreter.
Changed in version 2.4:
The useTk parameter was added.
Tcl( |
screenName=None, baseName=None, className='Tk', useTk=0) |
-
The Tcl function is a factory function which creates an object
much like that created by the Tk class, except that it does not
initialize the Tk subsystem. This is most often useful when driving the Tcl
interpreter in an environment where one doesn't want to create extraneous
toplevel windows, or where one cannot (i.e. Unix/Linux systems without an X
server). An object created by the Tcl object can have a Toplevel
window created (and the Tk subsystem initialized) by calling its
loadtk method.
New in version 2.4.
Other modules that provide Tk support include:
- ScrolledText
- Text widget with a vertical scroll bar built in.
- tkColorChooser
- Dialog to let the user choose a color.
- tkCommonDialog
- Base class for the dialogs defined in the other modules listed here.
- tkFileDialog
- Common dialogs to allow the user to specify a file to open or save.
- tkFont
- Utilities to help work with fonts.
- tkMessageBox
- Access to standard Tk dialog boxes.
- tkSimpleDialog
- Basic dialogs and convenience functions.
- Tkdnd
- Drag-and-drop support for Tkinter.
This is experimental and should become deprecated when it is replaced
with the Tk DND.
- turtle
- Turtle graphics in a Tk window.
Release 2.4c1, documentation updated on 18 November 2004.
See About this document... for information on suggesting changes.