Python | Text Area and Button in Tkinter

In this tutorial, we will learn how we can create text area and buttons, and how they work in Tkinter (Python), their implementations with examples?
Submitted by Abhinav Gangrade, on July 05, 2020




Tkinter(Tk interface) is a Standard python library that is used to create easy, fast, and simple GUI applications.

Download Tkinter:

General Way:
pip install python-tk

Pycharm Users:
Go to the project interpreter and install tkinter from there.

In this tutorial, we will create a label and text area, and we will extract the text from the text area, and we will see the functioning of the buttons.

Tkinter functions

  1. Importing all the inner functions of the Tkinter: from tkinter import *
  2. Creating Root: root=Tk(), this function will create the root window.
  3. Setting Geometry: root.geometry("500x500") we can set the geometry.
  4. Setting Title: root.title("<Set the title>") we can set the title with the help of this function
  5. Creating Label: Label(root,text="Hello"), we can set the label with the help of this function.
  6. Creating Text areas: Input(root,textvariable=<set text variable>,width=<set width>)
  7. Creating Buttons: Button(root,text="<Set text>",command=<set funnction>,bg=<set background color>)
  8. Running Loop: root.mainloop(), without running this function we will not be able to open the window.


# import the module and all specifications
from tkinter import *

# create the window and set geometry and title
root.title("Include Help")

# creating the commanding 
# function of the button
def get_value():
    # creating a new window
    root2.title("Include Help")
    # setting the Label in the window
    label2=Label(root2,text=f"Welcome To Include Help {name}"), y=80)

# set the string variable

# create a label
label=Label(root,text="Enter Your Name")

# placing the label at the right position,y=80)

# creating the text area
# we will set the text variable in this

# create a button


Python | Text Area and Button in Tkinter (Output)

This is the output, so in the above code we have done like we will take the name with the help of text area and after pressing the button, the commands of function will work and we will pop the new window where our name will get displayed.

Comments and Discussions!

Load comments ↻

Copyright © 2024 All rights reserved.