Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python tkinter change label text

from tkinter import *

root = Tk()
root.title('Test')


def change_text():
    print(my_label)
    my_label.config(text='new text')
    my_label.grid(row=0, column=0)


# create
my_label = Label(root, text='Hello World')
my_button = Button(root, text='click me', command=change_text, bg='#FFFF00')

# draw
my_label.grid()
my_button.grid()

# run
root.mainloop()
Comment

how to get the text from a label in tkinter

l = tk.Label(text="hello, world")
...
print("the label is", l.cget("text"))
#Outputs: the labels is hello, world
Comment

How to get the Tkinter Label text

l = tk.Label(text="hello, world")
...
print("the label is", l.cget("text"))
Comment

PREVIOUS NEXT
Code Example
Python :: Numpy split array into chunks of equal size 
Python :: email validation using django 
Python :: infinite for loop python 
Python :: calendar module in python 
Python :: read header of csv file python 
Python :: python scatter size 
Python :: how to open chrome console in selenium webdriver 
Python :: numpy find index of matching values 
Python :: how to check if a list is empty in python 
Python :: time series python 
Python :: add in python 
Python :: pathlib change extension 
Python :: use decorator in class python 
Python :: first non repeating charcter in string ython 
Python :: how to check if string ends with specific characters in python 
Python :: string to list of characters python 
Python :: python webscraper stack overflow 
Python :: data.head on terminal 
Python :: python calculator app 
Python :: discord api python putting ids in a list 
Python :: unocode error pytonn 
Python :: how to use self.list.setCurrentRow() in pyqt5 
Python :: python enforcing class variables in subclass 
Python :: roll dice python 
Shell :: get cpu frequency linux 
Shell :: ubuntu remove kite 
Shell :: the windows subsystem for linux component is not enabled 
Shell :: ubuntu restart mariadb 
Shell :: bash: gedit: command not found 
Shell :: AppImages require FUSE to run. 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =