As with most other modern Tk bindings, Tkinter is implemented as a Python wrapper around a complete Tclinterpreter 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.
This term has different meanings in different contexts, but in general it refers to a rectangular area somewhere on the user's display screen.
Top-level windowedit
A window which acts as a child of the primary window. It will be decorated with the standard frame and controls for the desktop manager. It can be moved around the desktop and can usually be resized.
Widgetedit
The generic term for any of the building blocks that make up an application in a graphical user interface.
Core widgets: The containers: frame, labelframe, toplevel, paned window. The buttons: button, radiobutton, checkbutton (checkbox), and menubutton. The text widgets: label, message, text. The entry widgets: scale, scrollbar, listbox, slider, spinbox, entry (singleline), optionmenu, text (multiline), and canvas (vector and pixel graphics).
Tkinter provides three modules that allow pop-up dialogs to be displayed: tk.messagebox (confirmation, information, warning and error dialogs), tk.filedialog (single file, multiple file and directory selection dialogs) and tk.colorchooser (colour picker).
Python 2.7 and Python 3.1 incorporate the "themed Tk" ("ttk") functionality of Tk 8.5.[6][7] 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). Some widgets are exclusive to ttk, such as the combobox, progressbar, treeview, notebook, separator and sizegrip.[8]
Frameedit
In Tkinter, the Frame widget is the basic unit of organization for complex layouts. A frame is a rectangular area that can contain other widgets.
Child and parentedit
When any widget is created, a parent–child relationship is created. For example, if you place a text label inside a frame, the frame is the parent of the label.
A minimal applicationedit
Here is a minimal Python 3 Tkinter application with one widget:[9]
#!/usr/bin/env python3fromtkinterimport*root=Tk()# Create the root (base) window w=Label(root,text="Hello, world!")# Create a label with wordsw.pack()# Put the label into the windowroot.mainloop()# Start the event loop
For Python 2, the only difference is the word "tkinter" in the import command will be capitalized to "Tkinter".[10]
pack it into position so it becomes visible. Developers also have the option to use .grid() (row=int, column=int to define rows and columns to position the widget, defaults to 0) and .place() (relx=int or decimal, rely=int or decimal, define coordinates in the frame, or window).
Bind
bind it to a function or event.
These are often compressed, and the order can vary.
Simple applicationedit
Using the object-oriented paradigm in Python, a simple program would be (requires Tcl version 8.6, which is not used by Python on MacOS by default):