Next / Previous / Contents / TCC Help System / NM Tech homepage

Abstract

Describes the Tkinter widget set for constructing graphical user interfaces (GUIs) in the Python programming language.

This publication is available in Web form and also as a PDF document. Please forward any comments to tcc-doc@nmt.edu.

Table of Contents

1. What is Tkinter?
2. A minimal application
3. Definitions
4. Layout management
4.1. The .grid() method
4.2. Other grid management methods
4.3. Configuring column and row sizes
4.4. Making the root window resizeable
5. Standard attributes
5.1. Dimensions
5.2. The coordinate system
5.3. Colors
5.4. Type fonts
5.5. Anchors
5.6. Relief styles
5.7. Bitmaps
5.8. Cursors
5.9. Images
5.10. Geometry strings
5.11. Window names
5.12. Cap and join styles
5.13. Dash patterns
5.14. Matching stipple patterns
6. The Button widget
7. The Canvas widget
7.1. Canvas coordinates
7.2. The Canvas display list
7.3. Canvas object IDs
7.4. Canvas tags
7.5. Canvas tagOrId arguments
7.6. Methods on Canvas widgets
7.7. Canvas arc objects
7.8. Canvas bitmap objects
7.9. Canvas image objects
7.10. Canvas line objects
7.11. Canvas oval objects
7.12. Canvas polygon objects
7.13. Canvas rectangle objects
7.14. Canvas text objects
7.15. Canvas window objects
8. The Checkbutton widget
9. The Entry widget
9.1. Scrolling an Entry widget
10. The Frame widget
11. The Label widget
12. The LabelFrame widget
13. The Listbox widget
13.1. Scrolling a Listbox widget
14. The Menu widget
14.1. Menu item creation (coption) options
14.2. Top-level menus
15. The Menubutton widget
16. The Message widget
17. The OptionMenu widget
18. The PanedWindow widget
18.1. PanedWindow child configuration options
19. The Radiobutton widget
20. The Scale widget
21. The Scrollbar widget
21.1. The Scrollbar command callback
21.2. Connecting a Scrollbar to another widget
22. The Spinbox widget
23. The Text widget
23.1. Text widget indices
23.2. Text widget marks
23.3. Text widget images
23.4. Text widget windows
23.5. Text widget tags
23.6. Setting tabs in a Text widget
23.7. The Text widget undo/redo stack
23.8. Methods on Text widgets
24. Toplevel: Top-level window methods
25. Universal widget methods
26. Standardizing appearance
26.1. How to name a widget class
26.2. How to name a widget instance
26.3. Resource specification lines
26.4. Rules for resource matching
27. Connecting your application logic to the widgets
28. Control variables: the values behind the widgets
29. Focus: routing keyboard input
30. Events
30.1. Levels of binding
30.2. Event sequences
30.3. Event types
30.4. Event modifiers
30.5. Key names
30.6. Writing your handler: The Event class
30.7. The extra arguments trick
30.8. Virtual events
31. Pop-up dialogs
31.1. The tkMessageBox dialogs module
31.2. The tkFileDialog module
31.3. The tkColorChooser module

1. What is Tkinter?

Tkinter is a GUI (graphical user interface) widget set for Python. This document contains only the commoner features.

This document applies to Python 2.5 and Tkinter 8.4 running in the X Window system under Linux. Your version may vary.

Pertinent references:

We'll start by looking at the visible part of Tkinter: creating the widgets and arranging them on the screen. Later we will talk about how to connect the face—the “front panel”—of the application to the logic behind it.