简体   繁体   English

如何在Pygubu / Python中更改标签文本

[英]How to change label text in Pygubu / Python

Im trying to change label text property of Label in Pygubu GUI builder for Tkinter with code: 我正在尝试使用以下代码在Tkinter的Pygubu GUI构建器中更改Label的label文本属性:

    fps_lable = self.builder.get_object('FPS_Label')
    txt = fps_lable.cget('text')
    print(txt)
    fps_lable.config(text='hello')

But nothing happens. 但是什么也没发生。 I get the text from label and it prints out (txt var) but when trying to change the text to "hello"... no joy. 我从标签获取了文本,并打印了出来(txt变种),但是当尝试将文本更改为“ hello”时……就没有乐趣了。 Any ideas why ? 有什么想法吗?

Try 尝试

fps_lable = self.builder.get_object('FPS_Label')
fps_lable.set('hello') # sets label to 'hello'

NOTE: FPS_Label must be the name of the 'textvariable' for the label in the gui. 注意:FPS_Label必须是gui中标签的“ textvariable”名称。

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

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