python-Tkinter复选框(四)

python-Tkinter复选框(四)

from tkinter import *
'''
复选框:Checkbutton()
'''
root = Tk()
list1 = ['李白','杜甫','李清照','唐伯虎','王昭君','西施']
v=[]

for tem in list1:
    v.append(IntVar())
    b = Checkbutton(root,text=tem,variable=v[-1])
    # anchor来改变定位方式,-anchor一共有8个参数可选,分别是:n,ne,e,se,s,sw,w,nw,
    # 其中单词n表示north,s表示south,e表示east,w表示weast,其他的组合也很容易知道具体位置。
    b.pack(anchor=SE)

mainloop()

猜你喜欢

转载自blog.csdn.net/m0_38039437/article/details/80539593