In this tutorial, I will explain how to display data in textboxes using Python Tkinter. Recently in one of my projects, I came across a scenario where I needed to display data in textboxes, then I explored more about this topic and I will share my findings with practical examples and screenshots.
Display Data in Textboxes using Python Tkinter
Tkinter offers two main widgets for displaying and inputting text:
- Entry: The Entry widget allows users to input a single line of text. It’s ideal for capturing small amounts of data like names, email addresses, or search queries.
- Text: The Text widget is used for displaying and editing multi-line text. It’s suitable for larger amounts of data or when you need formatting options.
Let’s get into an example to understand how to display data in textboxes.
Read How to Create an On/Off Toggle Switch in Python Tkinter?
Example 1: Customer Information Display
Suppose you’re building a customer management application for a company based in the USA. You need to display customer information in a textbox when the user selects a customer from a list. Here’s how you can achieve this using Python Tkinter:
import tkinter as tk
def display_customer_info(event):
selected_customer = customer_listbox.get(customer_listbox.curselection())
customer_info = get_customer_info(selected_customer)
customer_textbox.delete("1.0", tk.END)
customer_textbox.insert(tk.END, customer_info)
def get_customer_info(customer):
# Simulated customer data
customers = {
"John Smith": "Age: 35\nEmail: john@example.com\nPhone: (123) 456-7890",
"Emily Johnson": "Age: 42\nEmail: emily@example.com\nPhone: (987) 654-3210",
"Michael Davis": "Age: 28\nEmail: michael@example.com\nPhone: (555) 123-4567"
}
return customers.get(customer, "Customer not found")
# Create the main window
window = tk.Tk()
window.title("Customer Information")
# Create a listbox to display customer names
customer_listbox = tk.Listbox(window)
customer_listbox.pack()
# Add sample customer names to the listbox
customer_listbox.insert(tk.END, "John Smith")
customer_listbox.insert(tk.END, "Emily Johnson")
customer_listbox.insert(tk.END, "Michael Davis")
# Create a textbox to display customer information
customer_textbox = tk.Text(window, height=10, width=40)
customer_textbox.pack()
# Bind the listbox selection event to display customer info
customer_listbox.bind("<<ListboxSelect>>", display_customer_info)
window.mainloop()In this example:
- We create a listbox (
customer_listbox) to display a list of customer names. - We create a textbox (
customer_textbox) to display the selected customer’s information. - When the user selects a customer from the listbox, the
display_customer_info()function is called. - The selected customer’s information is retrieved using the
get_customer_info()function, which simulates fetching data from a database or API. - The textbox is cleared using
customer_textbox.delete(), and the customer information is inserted usingcustomer_textbox.insert().
You can see the output in the screenshot below.

Check out How to Validate User Input in Python Tkinter?
Format Data in Textboxes
When displaying data in textboxes, you may want to format it for better readability. Tkinter’s Text widget supports basic formatting options. Here are a few examples:
- Bold Text: Use the
**text**syntax to make text bold. - Italic Text: Use the
*text*syntax to make text italic. - Bullet Points: Use hyphens (
-) or asterisks (*) followed by a space to create bullet points.
Here’s an example of formatting customer information:
def get_customer_info(customer):
customers = {
"John Smith": "**Name:** John Smith\n**Age:** 35\n**Email:** john@example.com\n**Phone:** (123) 456-7890",
"Emily Johnson": "**Name:** Emily Johnson\n**Age:** 42\n**Email:** emily@example.com\n**Phone:** (987) 654-3210",
"Michael Davis": "**Name:** Michael Davis\n**Age:** 28\n**Email:** michael@example.com\n**Phone:** (555) 123-4567"
}
return customers.get(customer, "Customer not found")You can see the output in the screenshot below.

Read How to Create a Search Box with Autocomplete in Python Tkinter?
Display Tabular Data
If you need to display tabular data in a textbox, you can use Tkinter’s Tksheet widget or create a custom table using the Text widget. Here’s an example using the Tksheet widget:
import tkinter as tk
import tksheet
# Create the main window
window = tk.Tk()
window.title("Customer Data")
# Create a Tksheet widget
sheet = tksheet.Sheet(window)
sheet.pack()
# Add sample data to the sheet
data = [
["Name", "Age", "Email", "Phone"],
["John Smith", "35", "john@example.com", "(123) 456-7890"],
["Emily Johnson", "42", "emily@example.com", "(987) 654-3210"],
["Michael Davis", "28", "michael@example.com", "(555) 123-4567"]
]
sheet.set_sheet_data(data)
window.mainloop()You can see the output in the screenshot below.

In this example, we create a Tksheet widget and populate it with sample customer data. The Tksheet widget provides a spreadsheet-like interface for displaying and editing tabular data.
Check out How to Create Message Boxes with Python Tkinter?
Example 2:
We have used entry widgets to capture the information provided by the user, and then we have to frame a sentence & that sentence is displayed in another Entry widget.
from tkinter import *
def frame_sentence():
name = name_tf.get()
age = int(age_tf.get())
desc = descipline_tf.get()
disp_tf.insert(0,f'{age} years old {name} became {desc}.')
ws = Tk()
ws.title('PythonGuides')
ws.geometry('400x300')
ws.config(bg='#0f4b6e')
name_tf = Entry(ws)
age_tf = Entry(ws)
descipline_tf = Entry(ws)
name_lbl = Label(
ws,
text='Name',
bg='#0f4b6e',
fg='white'
)
age_lbl = Label(
ws,
text='Age',
bg='#0f4b6e',
fg='white'
)
descipline_lbl = Label(
ws,
text='Descipline',
bg='#0f4b6e',
fg='white'
)
name_lbl.pack()
name_tf.pack()
age_lbl.pack()
age_tf.pack()
descipline_lbl.pack()
descipline_tf.pack()
btn = Button(
ws,
text='Frame Sentence',
relief=SOLID,
command=frame_sentence
)
btn.pack(pady=10)
disp_tf = Entry(
ws,
width=38,
font=('Arial', 14)
)
disp_tf.pack(pady=5)
ws.mainloop()You can see the output in the screenshot below.

It is the interface wherein the user can fill in the information and can click on the frame sentence button, after clicking on the frame sentence button as a result of which a sentence has been displayed using provided information.
Read How to Save Text to a File Using Python Tkinter?
Conclusion
In this tutorial, I have explained how to display data in textboxes using Python Tkinter. I discussed an example of customer information display and we saw how to format data in textbox. I also discussed how to display tabular data and an example.
You may like to read:
- How to Cancel Scheduled Functions with after_cancel() in Python Tkinter?
- How to Create GUI Layouts with Python Tkinter Separator?
- How to Add Functions to Python Tkinter?

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.