Python 的Tkinter中的label,怎样让它的text自动更新
1个回答
2019-08-30 · 知道合伙人软件行家
关注
展开全部
from tkinter import *
from threading import Timer
from random import randint
def autoText():
....global timer,var
....var.set(str(randint(1,100)))
....timer = Timer(1, autoText)
....timer.start()
win=Tk()
var = StringVar()
var.set('1')
lb1 = Label(textvariable = var,width = 10,height = 3 )
lb1.pack()
timer = Timer(1, autoText)
timer.start()
win.mainloop()
from threading import Timer
from random import randint
def autoText():
....global timer,var
....var.set(str(randint(1,100)))
....timer = Timer(1, autoText)
....timer.start()
win=Tk()
var = StringVar()
var.set('1')
lb1 = Label(textvariable = var,width = 10,height = 3 )
lb1.pack()
timer = Timer(1, autoText)
timer.start()
win.mainloop()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询