-- Basic Widget 基础小组件
————— Check buttons and radio button ——————————
定义:
引导用户做出选择, 这些按钮可以帮助记录这些选项
check button 和 radio button 都包含一个value
区别:
Check Button: 只能选择 是 或者 否
Radio Button
_______________________________________
使用:
Check button:
存储数据:
BooleanVar, DoubleVar, IntVar, StringVar
如果我们想把checkbutton的数据存下来
store = StringVar()
store.set('Yes!')
# return the value in the variable
store.get()
# configure the check button
checkbutton.config(variable = store)
# onvalue is if the button is selected
checkbutton.config(onvalue = 'Yes plz', offvalue = 'No!'))
默认的存储是 1 是选中的, 0 是没有选中的
get() 返回button当前的状态
——————————————————
Radio Button:
Variable 代表这些button是一个系列
—————————————————————————
更改:
如果想更改设置:
label.config( arg = )
arg 可以是 text / image / font ...
—————————————————————————
More:
checkbutton.config(textvariable = breakfast)
如果breakfast radio button 你选中的是什么
checkbutton 的文字就会变成你选中的 text