Answer:
See the explanation
Explanation:
tkinter toolkit
- Easy to use
- Easy to learn
- Easy to debug
- Good for simple tasks
- TkInter applications are simpler as compared to PyQt because it is included in standard Python distribution.
- Faster than PyQt.
- Does not have advanced widgets.
- No interface builder available.
- Free for commercial utilization.
PyQt
- More flexible in terms of coding.
- Harder to debug as compared to tkinter
- GUI is clearer in display than tkinter
- Widgets are more interactive than that of tkinter
- size of a PyQt program is larger than that of tkinter
- uses a variety of paltform APIs and gives primary access to these APIs through a unique API.
- Has an interface builder that allows to design interfaces without writing any code.
- Has modern widgets.
- Due to its vast interface and several UI components it is a bit confusing to learn as compared to tkinter.
- Commercial license is required to release the code.
- Cross-platform and native GUI.
Widgets are GUI components such as buttons, labels, menus.
a) Label
This is a tkinter widget to show the text or image on the screen. It looks like a display box. The user can easily edit or update label.
For example to display a label with text "Hello World" the following chunk of code is used:
import tkinter
widget = tkinter.Tk()
label =tkinter.Label(widget, text="Hello World")
label.pack()
tkinter.mainloop()
b) Entry
This is a tkinter widget to accept the text input from user. For example if you want to get a single line text from user then you can use Entry widget. The code below displays an entry widget with the message: Enter input text: Here the user can input the text.
import tkinter
widget = tkinter.Tk()
entry = tkinter.Entry(widget)
entry.insert(0, "Enter input text:")
entry.pack()
tkinter.mainloop()
c) Button
This is a tkinter widget to add a button in an application. You can enter some text or an image in this button convey its purpose. When you click on the button a function is called or an event is emitted.
The following chunk of code displays a button with the text "Click Me" on the button.
import tkinter
widget = tkinter.Tk()
button = tkinter.Button(widget, text="Click Me")
button.pack()
tkinter.mainloop()
d) Frame
This is a tkinter widget to group together and organize other widgets and arranges their position.
The following chunk of code displays an outer frame with a label with text "parent label" and an inner frame with a label of text "child frame".
import tkinter
widget = tkinter.Tk()
frame = tkinter.LabelFrame(widget,text="parent frame")
label= tkinter.Label(frame,text="child frame")
frame.pack(padx=10, pady=10)
label.pack()
tkinter.mainloop()