lb=Text(root)
lb.place(x=20,y=160,width=200,height=200)
lb.tag_config('样式1', foreground='red')
lb.tag_config('样式2', foreground='black')
lb.tag_config('样式3', foreground='black',background="yellow")
def guess():
lb.config(state=NORMAL)
a=enternumber.get()
if a=="":
lb.insert(END,"不能为空!\n","样式1")
elif not a.isdigit():
lb.insert(END,"必须是数字!\n","样式1")
elif eval(a)<0 or eval(a)>100:
lb.insert(END,"不能小于0或者大于100!\n","样式1")
elif 0<=eval(a)<20:
lb.insert(END,"太小了!\n","样式2")
elif 20<eval(a)<=100:
lb.insert(END,"太大了!\n","样式2")
elif eval(a)==20:
lb.insert(END,"猜对了!\n","样式3")
def clear():
enternumber.delete(0,END)
lb.delete(0,END)
lb.config(state=DISABLED)