Radiobutton

 1 from tkinter import *
 2 
 3 root = Tk()
 4 v = IntVar()
 5 
 6 LANGS=[
 7     ('Python',1),
 8     ('Perl',2),
 9     ('Ruby',3),
10     ('Lua',4)
11     ]
12 v = IntVar()
13 v.set(1)
14 
15 for lang,num in LANGS:
16     Radiobutton(root,text=lang,variable = v,value=num,indicatoron=False).pack(anchor= W,fill=X)
17     #这里注意,variables其实是button本身的值,它等于谁,就决定了button的默认值
18     #在这里设定了v = 1,也即variable=1,所以button默认就指向值为一的选项
19 
20 root.mainloop()
原文地址:https://www.cnblogs.com/themost/p/6761930.html