-- Basic Widget 基础小组件
——————— Button————————————
定义:
按钮往往并不包含文字图片内容
大多时候意味着要用户去点击它
是一种交互工具
_______________________________________
使用:
b= ttk.Button(root, text, command)
b.pack()
_______________________________________
实例:
import tkinter as tk
def write_slogan():
print("Tkinter is easy to use!")
root = tk.Tk()
frame = tk.Frame(root)
frame.pack()
button = tk.Button(frame,
text="QUIT",
fg="red",
command=quit)
button.pack(side=tk.LEFT)
slogan = tk.Button(frame,
text="Hello",
command=write_slogan)
slogan.pack(side=tk.LEFT)
root.mainloop()
—————————————————————————
更改:
如果想更改设置:
label.config( arg = )
—————————————————————————
More:
b.invoke() # 在command line 模拟 点击 button
b.state(['disabled']) # button会变灰 无法使用
instate(state) # check if is the state