python-tkinter-02-check/radioButton
2019-02-13 20:04
162 查看
- CheckButton多选框控件
[code]import tkinter win = tkinter.Tk() win.title("xinghaohan") win.geometry("400x400+200+20") def updata(): message = "" if hobby1.get() == True: message += "money\n" if hobby2.get() == True: message += "power\n" if hobby3.get() == True: message += "ggril\n" #清除text中的所有内容 text.delete(0.0, tkinter.END) text.insert(tkinter.INSERT, message) #要绑定的变量 hobby1 = tkinter.BooleanVar() #多选框 check1 = tkinter.Checkbutton(win, text="money", variable=hobby1, command=updata) check1.pack() hobby2 = tkinter.BooleanVar() check2 = tkinter.Checkbutton(win, text="power", variable=hobby2, command=updata) check2.pack() hobby3 = tkinter.BooleanVar() check3 = tkinter.Checkbutton(win, text="ggril", variable=hobby3, command=updata) check3.pack() text = tkinter.Text(win, width=50,height=5) text.pack() win.mainloop()
- Radiobutton单选框控件
[code]import tkinter win = tkinter.Tk() win.title("xinghaohan") win.geometry("400x400+200+20") def updata(): print(r.get()) #一组单选框要绑定同一个变量 r = tkinter.IntVar() radio1 = tkinter.Radiobutton(win, text="one", value=1, variable=r, command=updata) radio1.pack() radio2 = tkinter.Radiobutton(win, text="two", value=2, variable=r, command=updata) radio2.pack() # ============================================================================= #默认都选中 # r = tkinter.StringVar() # radio1 = tkinter.Radiobutton(win, text="one", value="good", variable=r, # command=updata) # radio1.pack() # radio2 = tkinter.Radiobutton(win, text="two", value="nice", variable=r, # command=updata) # radio2.pack() # ============================================================================= win.mainloop()
相关文章推荐
- Python之tkinter:动态演示调用python库的tkinter带你进入GUI世界(LabelFrame/Checkbutton/Radiobutton)——Jason niu
- Python3 Tkinter基础 LabelFrame Radiobutton 形成两组不相互限制的单选按钮
- Python--Tkinter之 Button()/Checkbutton()/Radiobutton()
- Python Tkinter Checkbutton的使用
- Python3 Tkinter基础 Checkbutton Label Label显示是否被选中
- python Tkinter之Button
- MFC控件使用说明(combo box Button Check Box Radio Button List Control Edit Box Hot Key IP Address....)
- Python3 Tkinter基础 Radiobutton 设置indicatoron=False 改变按钮的外观 从圆形变为button的形状
- MFC控件使用说明(combo box Button Check Box Radio Button List Control Edit Box Hot Key IP Address....)
- MFC控件使用说明(combo box Button Check Box Radio Button List Control Edit Box Hot Key IP Address)
- rails date/time field/radio_button/check_box
- Python3 Tkinter基础 Button bg 设置按钮的背景颜色
- tkinter之checkbutton
- Python的TkinterButton做为父窗口
- python tkinter学习 之Label,Button,Listbox
- Python tkinter 用例 含button label Entry
- CheckRadioButton 函数
- python GUI--Tkinter(2):控件Button、Checkbutton、Radiobutton
- Python之tkinter:动态演示调用python库的tkinter带你进入GUI世界(Button的command/Label/PhotoImage/封装为类)——Jason niu
- Python学习笔记_02:使用Tkinter连接MySQL数据库实现登陆注册功能