Tkinter is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit,[1] and is Python's de facto standard GUI.[2] Tkinter is included with standard Linux, Microsoft Windows and macOS installs of Python.
The name Tkinter comes from Tk interface. Tkinter w...
Tkinter is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit,[1] and is Python's de facto standard GUI.[2] Tkinter is included with standard Linux, Microsoft Windows and macOS installs of Python.
The name Tkinter comes from Tk interface. Tkinter was written by Steen Lumholt and Guido van Rossum,[3] then later revised by Fredrik Lundh.[4]
Tkinter is free software released under a Python license.[5]
Description
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.
There are several popular GUI library alternatives available, such as Kivy, Pygame, Pyglet, PyGObject, PyQt, PySide, and wxPython.
Some definitions
Window
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 window
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.
Widget
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]
Frame
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 parent
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 application
Here is a minimal Python 3 Tkinter application with one widget:[9]
#!/usr/bin/env python3
from tkinter import *
root = Tk() # Create the root (base) window
w = Label(root, text="Hello, world!") creating label by tkintr
Size: 906.1 KB
Language: en
Added: Aug 22, 2024
Slides: 13 pages
Slide Content
PYTHON – TKINTER BY M.SUMANA SREE MSC COMPUTER SCIENCE 1 ST YEAR ARK DEGREE & PG COLLEGE
USER INTERFACE User interface allow the user to interact with electronic devices. Generally we have two types of user interfaces which are CLI – (Command Line Interface) Command line interface is operated by using commands and used in Linux Operating system GUI – (Graphical User Interface) Graphical user interface is operated by using graphical icons and visual indicators commonly used in Windows OS
Python Libraries For GUI Python provides various options for developing graphical user interfaces (GUIs). Most important are listed below Tkinter wxPython Jpython and other etc
Here are the some other Python GUI Libraries as shown in the above figure Kivy PythonQt
Tkinter ? Tkinter is the standard (default) GUI library for Python. Python when combined with Tkinter provides a fast and easy way to create GUI applications. Tkinter provides a powerful object-oriented interface to the Tk GUI toolkit. It is based on the Tk toolkit, originally designed for the (TCL) Tool Command Language. Due to Tk’s popularity, it has been ported to a variety of other scripting languages, including Perl (Perl/Tk), Ruby (Ruby/Tk) and Python ( Tkinter ).
It is a platform independent can use in (Unix/Windows/Mac) Operating systems. Popular open-source scripting language/GUI widget set developed by John Ousterhout in 90s FEATURES : Easy to use Cross-platform Highly customizable
KEY FEATURES Widgets: Tkinter provides various controls used in GUI application. These controls are commonly called Widgets (buttons, labels etc ). Layouts: Layout Management - Organizing widgets with ease using the pack(), grid() and place(). Events: Handling Events – Using command callbacks or bind events to respond to user interactions with event-driven programming. Tkinter provides various options and styles for customization.
Creating a GUI application is using Tkinter is an easy task. All you need to do is to perform the following steps- Import Tkinter module Create the GUI application main window Add one or more widgets to the GUI application Enter the main event loop to take action against each event triggered by the user. Creating GUI application using Tkinter
Simple way to remember!
Example : #!/usr/bin/python import tkinter top = tkinter.Tk () #Code to add widgets will go here.. top.mainloop () This would create a following window
REAL-WORLD APPLICATIONS
CONCLUSION : “ Tkinter is a powerful and easy-to-use GUI library for Python ”