python tkinter中的label怎么实行动态改变

~Really~ 2020-03-11 01:02:15
from tkinter import *
import tkinter.messagebox
def autoText():
global str,n

while n<10:

n=n+1

str.set(n)
n=0
root = tkinter.Tk()

str=StringVar() #StringVar是一个很强大的类,可以辅助控件动态改变值
root.geometry('300x250')
str.set('1')
warning = Label(root, textvariable=str) # 用于显示警告信息
warning.place(x=30, y=120, anchor='nw')
tkinter.Button(root, text='确认', width=10, height=1, command=autoText).place(x=150, y=115)
root.update()
root.mainloop()
...全文
1620 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
SeerMi 2020-03-18
  • 打赏
  • 举报
回复 1
楼主太不地道了, 我的答案是正确的,竟然不结贴 ... 以后低结帖率的人,根本不用理
SeerMi 2020-03-12
  • 打赏
  • 举报
回复
warning .config(text="你的新提示")
~Really~ 2020-03-11
  • 打赏
  • 举报
回复
顶一下.................................

37,721

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧