tkinter – Components

Previous
Next

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:

  1. Button: Used to create buttons on window.
  2. Checkbutton: To display check list where we can select multiple options among specified
  3. Entry:  Text box appears from which we can take input in String format.T
  4. Frame: The Frame widget is used as a container widget to organize other widgets.
  5. Label: To display sticky test and images.
  6. Listbox: The Listbox widget is used to provide a list of options to a user.
  7. Menubutton: The Menubutton widget is used to display menus in your application.
  8. Menu: The Menu widget is used to provide various commands to a user. These commands are contained inside Menubutton.
  9. 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.
  10. 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.
Previous
Next

Add Comment

Courses Enquiry Form