- 1). Use the following commands to initialize a GUI:
from tkinter import *
root = Tk()
myLabel = Label(root, text='My text.')
myLabel.pack()
The second argument of the label's constructor ("text=...") is optional. When these commands are finished the label is visible in a new window. - 2). Replace the label's current text with new text using the "configure" method:
myLabel.configure(text='New Text.') - 3). Append text to the end of a label by using the "cget" method and the concatenation operator ("+") within the "configure" method:
myLabel.configure(text=myLabel.cget('text')+' APPENDED TEXT')
SHARE