DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk2 min

How to Get Text from a Tkinter Label in Python

Use label.cget("text") or label["text"] for a text-backed Tkinter Label. If it uses textvariable, get the current value from the linked Tk variable instead.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a text-backed Tkinter label, read its current text option with label.cget("text"). The equivalent shorthand is label["text"]. If the label uses textvariable, read the linked Tk variable with its .get() method instead.

Read the text option from a Label

Both classic tkinter.Label and themed ttk.Label support the standard widget option API. Use cget() when you want to make the read explicit:

text = label.cget("text")

Option indexing returns the same value:

text = label["text"]

Python’s Tkinter documentation describes cget() as retrieving a widget option’s current value and documents option indexing as equivalent. The call returns the option value as a string.

Complete classic Label example

import tkinter as tk

root = tk.Tk()
label = tk.Label(root, text="Hello")
label.pack()

print(label.cget("text"))  # Hello
root.mainloop()

You can also query an option with label.configure("text"). Use configure(text="New text") to change it; that form configures the widget rather than reading the option.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read text from a Label with textvariable

When a label is created with textvariable, the displayed value is linked to a Tk variable. Read the current value from that variable, not by treating the label’s text option as the source of truth:

import tkinter as tk
from tkinter import ttk

root = tk.Tk()
message = tk.StringVar(value="Ready")
label = ttk.Label(root, textvariable=message)
label.pack()

print(message.get())  # Ready
root.mainloop()

Keep a reference to the variable object while the widget uses it. Tkinter’s documentation notes that when a Variable object is garbage-collected, its Tcl variable is unset.

Does this work with ttk.Label?

Yes. A themed ttk.Label inherits the standard widget option methods, so for a label configured with text, use label.cget("text") or label["text"] just as you would with tkinter.Label. The ttk reference confirms the themed widget API; that URL documents Python 3.16.0a0 development documentation, not a released version.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What the text option does—and does not—tell you

A Tkinter Label can display a text string, bitmap, or image. Reading label.cget("text") gets the value of the text option; it does not extract words from an image or bitmap. If the label is displaying another kind of content, the text option may not describe what is visible.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A Label is non-interactive. If the user needs to edit text or work with a text area, use an appropriate Entry or Text widget rather than a Label.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.