tkinter学习笔记_01

知识点目录:
1、 文本框 Label
var = tk.StringVar()
# 文本框   bg 背景颜色   fonnt 字体设置    width 长   height 高
l = tk.Label(root, textvariable=var, bg='green', font=('Arial',12), width=15)
l.pack()
2、按钮 Button
 
on_hit = False
# 按钮
def hit_me():
    global on_hit
    if on_hit == False:
        on_hit = True
        var.set("sasdad")
    else:
        on_hit = False
        var.set("")

# command 执行动作
b = tk.Button(root, text='按钮', width=15, height=2, command=hit_me)
b.pack()

3、单行输入框     entry

# entry 单行输入框, show显示,掩码的话就show='*',
e = tk.Entry(root, show=None)
e.pack()

 
原文地址:https://www.cnblogs.com/lixy-88428977/p/9367027.html