Components:
- We design the form using components like Button, Label, Entry filed….
- Components are pre-defined classes belongs to “tkinter” module.
- After instantiation (object creation) of Component class, we can add to the Frame.
Some of the Component Classes are:
- Button: Used to create buttons on window.
- Checkbutton: To display check list where we can select multiple options among specified
- Entry: Text box appears from which we can take input in String format.T
- Frame: The Frame widget is used as a container widget to organize other widgets.
- Label: To display sticky test and images.
- Listbox: The Listbox widget is used to provide a list of options to a user.
- Menubutton: The Menubutton widget is used to display menus in your application.
- Menu: The Menu widget is used to provide various commands to a user. These commands are contained inside Menubutton.
- Radiobutton: The Radiobutton widget is used to display a number of options as radio buttons. The user can select only one option at a time.
- Scrollbar: The Scrollbar widget is used to add scrolling capability to various widgets, such as list boxes.
Creating Button:
from tkinter import Tk, Button
frame = Tk()
frame.title("GUI")
frame.geometry("500x300")
b = Button(frame, text="Click Me")
- In the above code, we are not using any bounds or layout to arrange the button on the Frame.
- We must use the Layout Management to arrange the components.
- Using the pre-defined functionality of Component, we can Layout that Component.