Tkinter - the Python interface for Tk
By Bernd Klein. Last modified: 01 Feb 2022.
We have often been asked: "Is there no Tk for Python?" or "Is Tkinter the same as Tk?" Of course, there is Tk for Python. Without Tk Python would be less attractive to many users. Tk is called Tkinter in Python, or to be precise, Tkinter is the Python interface for Tk. Tkinter is an acronym for "Tk interface".
Tk was developed as a GUI extension for the Tcl scripting language by John Ousterhout. The first release was in 1991. Tk proved as extremely successful in the 1990's, because it is easier to learn and to use than other toolkits. So it is no wonder that many programmers wanted to use Tk independently of Tcl. That's why bindings for lots of other programming languages have been developed, including Perl, Ada (called TASH), Python (called Tkinter), Ruby, and Common Lisp.
Tk provides the following widgets:
It provides the following top-level windows:
- tk_chooseColor - pops up a dialog box for the user to select a color.
- tk_chooseDirectory - pops up a dialog box for the user to select a directory.
- tk_dialog - creates a modal dialog and waits for a response.
- tk_getOpenFile - pops up a dialog box for the user to select a file to open.
- tk_getSaveFile - pops up a dialog box for the user to select a file to save.
- tk_messageBox - pops up a message window and waits for a user response.
- tk_popup - posts a popup menu.
- toplevel - creates and manipulates toplevel widgets.
Tk also provides three geometry managers:
- place - which positions widgets at absolute locations
- grid - which arranges widgets in a grid
- pack - which packs widgets into a cavity
Live Python training
Enjoying this page? We offer live Python training courses covering the content of this site.
In this chapter
|1. Labels in Tkinter||Tkinter Labels - GUI Programming with Python: Simple Examples|
|2. Message widget in Tkinter||The tkinter message widget under Python.|
|3. Buttons in Tkinter||Tk tutorial: Using Buttons in Tkinter under Python.|
|4. Variable Classes in Tkinter||Introducing Tkinter Variable Classes: StringVar, IntVar, DoubleVar and BooleanVar|
|5. Radio Buttons in Tkinter||This chapter deals with Radiobuttons in Tk and Tkinter under Python.|
|6. Checkboxes in Tkinter||Checkboxes in Tkinter with example applications|
|7. Entry Widgets in Tkinter||Tutorial on Tkinter: Communication with the User by using Entry Widgets|
|8. Canvas Widgets in Tkinter||Tutorial on Tkinter: Canvas Widgets|
|9. Sliders in Tkinter||Introduction to Sliders in Tkinter|
|10. Text Widget in Tkinter||Text input for web applications with Text widgets in Tkinter|
|11. Dialogs in Tkinter||Introduction to the standard dialogues of Tkinter.|
|12. Layout Management in Tkinter||Layout management under Tkinter and Python using pack, grid and place; GUI Programming with Python:|
|13. The Game of Life in Python||An implementation of game of Life. The focus is on teaching Python and Tkinter. GUI Programming with Python: Not really a Game:|
|14. Bulls and Cows / Mastermind in Tkinter||Implemenation of Bulls and Cows, also known as Mastermind in Tk /Tkinter|
|15. Menus in Tkinter||Designing and creating Menus in Tkinter GUI Programming with Python:|
|16. Events and Binds in Tkinter||Tutorial and Introduction on Tkinter: Using Events and Binds, GUI Programming with Python:|