Python has a lot of GUI frameworks, but Tkinter is the only framework that’s built into the Python standard library.
GUI is nothing but a desktop app that provides you with an interface that helps you to interact with the computers and enriches your experience of giving a command (command-line input) to your code.
Tkinter is a GUI Library for Python that enables the user to create GUI application. It is a powerful Object-Oriented Language. With this we can make the front end of the app easily.
It is used to construct buttons, text box, labels, etc. It improves user interaction to make the application more understandable and user friendly.
Tkinter comes with the python installer and we don’t have to install it from anywhere else.
To create a tkinter app:
- Importing the module – tkinter
- Create the main window (container)
- Add any number of widgets to the main window
- Apply the event trigger on the widgets.
We can easily import it and use it in python.
syntax:-
import tkinter as tk or import tkinter
In this way we can import it in text editor in python and use it .
Tk provides the following widgets:
- button
- canvas
- combo-box
- frame
- level
- check-button
- entry
- level-frame
- menu
- list – box
- menu button
- message
- tk_optoinMenu
- progress-bar
- radio button
- scroll bar
- separator
- tree-view, and many more.
import tkinter m = tkinter.Tk() m.mainloop()
This is all about tkinter in python.