Tkinter is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit and is Python's de facto standard GUI, and is included with the standard Windows and Mac OS X install of Python.
The name Tkinter comes from Tk interface. Tkinter was written by Fredrik Lundh.
As with most other modern Tk bindings, Tkinter is implemented as a Python wrapper around a complete Tcl interpreter embedded in the Python interpreter. Tkinter calls are translated into Tcl commands which are fed to this embedded interpreter, thus making it possible to mix Python and Tcl in a single application.
Python 2.7 and Python 3.1 incorporate the "themed Tk" ("ttk") functionality of Tk 8.5. This allows Tk widgets to be easily themed to look like the native desktop environment in which the application is running, thereby addressing a long-standing criticism of Tk (and hence of Tkinter).
Tkinter is usually part of Python. However, Tcl/Tk often is not. For information on getting Tcl/Tk/Tkinter installed on your platform, refer to How_to_Install_Tkinter
Several books mention Tkinter.
A Minimal Application
Here is a sample code:
import Tkinter as tk
def __init__(self, master=None):
self.quitButton = tk.Button(self, text='Quit', command=self.quit)
app = Application()
- line 1: This line makes the script self-executing, assuming that your system has Python correctly installed.
- line 2: This line imports the Tkinter module into your program's namespace, but renames it as tk.
- line 3: Your application class must inherit from Tkinter's Frame class.
- line 4: Calls the constructor for the parent class, Frame.
- line 5: Necessary to make the application actually appear on the screen.
- line 6: Creates a button labeled “Quit”.
- line 7: Places the button on the application.
- line 8: The main program starts here by instantiating the Application class.
- line 9: This method call sets the title of the window to “Sample application”.
- line 10: Starts the application's main loop, waiting for mouse and keyboard events.
- "Tkinter — Python interface to Tcl/Tk — Python v2.6.1 documentation". Retrieved 2009-03-12.
- "Tkinter - Pythoninfo Wiki".
- Shipman, John W. (2010-12-12), Tkinter reference: a GUI for Python, New Mexico Tech Computer Center, retrieved 2012-01-11
- "Python issue #2983, "Ttk support for Tkinter"".
- "Python subversion revision 69051, which resolves issue #2983 by adding the ttk module".
- "How to Install Tkinter in Python 2.7".
- "Tkinter 8.5 reference: a GUI for Python". Retrieved 2013-12-31.
- "TkInter", Python Wiki
- Lundh, Fredrik (1999), An Introduction to Tkinter
- TkDocs: includes language-neutral and Python-specific information and a tutorial
- Ferg, Stephen, Thinking in Tkinter
- PAGE - Python Automatic GUI Generator
- Visual Tkinter : A Tkinter based GUI builder for Python.
- Rapyd-Tk : A graphical development environment for writing applications in Tkinter.
- tkRAD : Tkinter Rapid Application Development and XML widget builder for Tkinter
|This free software–related article is a stub. You can help Wikipedia by expanding it.|