我创建一个StringVar,将它从属于一个标签,更改StringVar
的值,并且标签不会更新。你知道吗
class DlgConnection:
def start(self)
self.dlgConnection = Tk()
self.dlgConnection.title("Connection")
self.dlgConnection.geometry("380x400")
self.dlgConnection.resizable(width=False,height=False)
self.statusText = StringVar()
self.lStatusText = Label(self.dlgConnection, width=80, anchor="w", textvariable=self.statusText)
self.lStatusText.place(x = 0, y = 360, width=380, height=25)
self.setStatus("Welcome 2")
def setStatus(self, status_text):
print(status_text) #the print is just to show me I changed the text
self.statusText.set(status_text)
self.lStatusText.update() # I tried this out of desperation
我把你的代码改写成了有用的东西。窗口打开时显示文本“Initial”,然后每隔一秒在“Welcome 1”和“Welcome 2”之间切换一次。你知道吗
这个问题非常类似于Update Tkinter Label from variable
相关问题 更多 >
编程相关推荐