简体   繁体   English

Python更改当前的Tkinter文本

[英]Python change current tkinter text

I am making a tkinter window to show me the weather currently. 我正在制作一个tkinter窗口,向我显示当前的天气。 Every 5 minutes, it will get the new weather, and then replace the old text. 每隔5分钟,它将得到新的天气,然后替换旧的文本。

To put in the text, I am using a Tkinter Label. 要输入文字,我使用的是Tkinter标签。

T = Label(root, bg="black", fg="white", height=2, width=30, text="Some Text")

However, I looked on the internet, and I found a delete function, but it does not work with labels. 但是,我查看了Internet,发现了一个删除功能,但它不适用于标签。

How would I go about changing the label text? 我将如何更改标签文本?

I want to change the label while the program is still in mainloop. 我想在程序仍处于主循环中时更改标签。

You can use this way : 您可以使用这种方式:

T = Label(root, bg="black", fg="white", height=2, width=30, text="Some Text")
T.config(text='New text')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM