How to Change Label Text in Tkinter

Changing the text of a label is one of the most common tasks you will face when building a desktop application with Python.

I remember when I first started using Tkinter; I thought I had to destroy the label and create a new one every time the data changed.

It took me a while to realize that Tkinter provides much more efficient ways to update your UI dynamically.

In this tutorial, I will show you exactly how to change label text in Tkinter using three different methods I use in my daily development work.

Update Label Text Using the config() Method

The config() method (short for configuration) is my personal favorite because it is straightforward and doesn’t require extra variables.

In my experience, this is the most “Pythonic” way to handle quick updates, such as changing a status message or updating a price tag in a retail app.

Suppose you are building a simple application for a coffee shop in Seattle. You want the label to update when a user selects a drink size.

Here is the full code to achieve this:

import tkinter as tk

def update_price():
    # Update the label text using the config method
    label_price.config(text="Total: $5.50 (Large Latte)")

# Initialize the main window
root = tk.Tk()
root.title("Seattle Coffee House POS")
root.geometry("400x200")

# Initial static label
label_price = tk.Label(root, text="Total: $0.00", font=("Arial", 14))
label_price.pack(pady=20)

# Button to trigger the change
btn_update = tk.Button(root, text="Select Large Size", command=update_price, bg="green", fg="white")
btn_update.pack(pady=10)

root.mainloop()

I executed the code above and added the screenshot below.

Change Label Text in Tkinter

When you call label_price.config(text=”New Text”), Tkinter immediately redraws that component with the new string.

I find this method incredibly reliable for dashboards where you are monitoring server statuses or simple data inputs.

Use StringVar for Dynamic Data Binding

Another powerful way to change label text is by using a StringVar. This is a special Tkinter variable that acts as a wrapper around a Python string.

I often use this method when I have multiple widgets that need to stay in sync with the same piece of data.

Think of a “Tax Calculator” for a US-based payroll app. When the user enters their state, you want the label to reflect the tax rate immediately.

By tracing the StringVar, the label updates automatically whenever the variable’s value changes.

Here is how you can implement this:

import tkinter as tk

def calculate_tax():
    # Setting the value of the StringVar updates the label automatically
    state_name = "New York"
    tax_rate = "8.875%"
    text_variable.set(f"Current Tax in {state_name}: {tax_rate}")

root = tk.Tk()
root.title("US State Tax Info")
root.geometry("400x200")

# Create a StringVar object
text_variable = tk.StringVar()
text_variable.set("Select a state to see tax info")

# Link the Label to the StringVar using 'textvariable'
label_tax = tk.Label(root, textvariable=text_variable, font=("Verdana", 12), wraplength=350)
label_tax.pack(pady=30)

btn_calc = tk.Button(root, text="Check NY Tax", command=calculate_tax)
btn_calc.pack()

root.mainloop()

I executed the code above and added the screenshot below.

How to Change Label Text in Tkinter

One thing I’ve noticed is that using textvariable is much cleaner when your application grows in complexity.

It separates the data (the string) from the presentation (the label widget).

Change Text via Dictionary Indexing

If you are coming from a web development background, you might find this method very intuitive.

In Tkinter, widgets can be treated like dictionaries. You can access the ‘text’ property using square brackets.

I use this occasionally when I am looping through a list of widgets and need to update their properties dynamically.

Let’s look at an example involving a simple Flight Status tracker for an airport like JFK or LAX.

import tkinter as tk

def update_status():
    # Updating via dictionary-style indexing
    status_label["text"] = "Status: Delayed (Gate B12)"
    status_label["fg"] = "red"

root = tk.Tk()
root.title("JFK Flight Tracker")
root.geometry("400x200")

status_label = tk.Label(root, text="Status: On Time", font=("Helvetica", 14))
status_label.pack(pady=40)

btn_check = tk.Button(root, text="Refresh Status", command=update_status)
btn_check.pack()

root.mainloop()

I executed the code above and added the screenshot below.

Change Tkinter Label Text

This method is functionally identical to config(), but some developers prefer the syntax because it feels more like standard Python dictionary manipulation.

Handle Multi-line Text Updates

In many professional US business applications, you aren’t just changing a single word; you are updating descriptions or addresses.

When changing label text that is quite long, you must use the wraplength attribute.

I once spent an hour wondering why my text was disappearing off the side of the window before I remembered this trick.

If you are displaying a mailing address for a customer in Chicago, you want the text to wrap neatly within the label boundaries.

import tkinter as tk

def show_address():
    long_address = "123 W Madison St, Chicago, IL 60602, United States of America"
    address_label.config(text=long_address)

root = tk.Tk()
root.title("Customer Directory")
root.geometry("300x250")

# wraplength is in pixels
address_label = tk.Label(root, text="Click to load address", wraplength=250, justify="left")
address_label.pack(pady=50)

btn_load = tk.Button(root, text="Load Chicago Office", command=show_address)
btn_load.pack()

root.mainloop()

I executed the code above and added the screenshot below.

Change Label Text Tkinter

Using justify=”left” along with wraplength ensures that when the text changes, it looks like a professional document rather than a centered mess.

Update Labels Inside a Loop (Real-time Clock)

A common question I get is how to change a label’s text continuously, like a clock or a countdown timer for a New Year’s Eve app.

You cannot use a standard while True loop in Tkinter because it will freeze the UI.

Instead, I always use the .after() method. This tells Tkinter to wait a certain amount of time and then run a function to update the text.

Here is a full example of a digital clock showing the current time:

import tkinter as tk
import time

def tick():
    # Get the current local time
    current_time = time.strftime('%H:%M:%S %p')
    # Update the label text
    clock_label.config(text=current_time)
    # Call the tick function again after 1000ms (1 second)
    clock_label.after(1000, tick)

root = tk.Tk()
root.title("US Standard Time")
root.geometry("300x150")

clock_label = tk.Label(root, font=("Courier", 20, "bold"), fg="blue")
clock_label.pack(expand=True)

# Initial call to start the clock
tick()

root.mainloop()

This is the gold standard for creating dynamic, self-updating labels without crashing your program.

Why Your Label Text Might Not Be Updating

If you’ve followed the steps above and your text still isn’t changing, there are usually two culprits I see in my code reviews.

First, ensure you aren’t defining the label and calling .pack() on the same line.

For example, my_label = tk.Label(…).pack() will set my_label to None. You must pack it on a separate line to keep a reference to the object.

Second, make sure your update function is actually being triggered. I often add a print(“Triggered”) statement inside my functions just to verify the button logic is working.

In this tutorial, we looked at how to change label text in Tkinter using config(), StringVar, and dictionary indexing.

I also showed you how to handle wrapping for long strings and how to create a real-time updating clock.

You may also like to read:

51 Python Programs

51 PYTHON PROGRAMS PDF FREE

Download a FREE PDF (112 Pages) Containing 51 Useful Python Programs.

pyython developer roadmap

Aspiring to be a Python developer?

Download a FREE PDF on how to become a Python developer.

Let’s be friends

Be the first to know about sales and special discounts.