Python的tkinter标签和按钮

小项目:单击按钮,标签字符串改变

修改莫凡Python代码:莫烦Python

import tkinter as tk
window = tk.Tk()
window.title('666')
window.geometry('300x100')

var=tk.StringVar()
var.set('first Button')
theLabel=tk.Label(window,textvariable=var,
                  fg='yellow',bg='blue',
                  font=('宋体',15),width=20,height=2)
theLabel.pack()

hi_go=False
def first_Button():
    global hi_go
    if not hi_go:
        hi_go = True
        var.set('')
    else:
        hi_go = False
        var.set('first Button')

theButton=tk.Button(window,text='button001',command=first_Button,
                    width=15,height=2)
theButton.pack()

window.mainloop()

Python的tkinter标签和按钮

Python的tkinter标签和按钮 

 

上一篇:el-button点击了按钮之后,将鼠标移出按钮,会出现保留点击的状态


下一篇:vue中install方法