基本信息
源码名称:python 入门级windows示例源码(桌面应用程序)
源码大小:5.01KB
文件格式:.rar
开发语言:Python
更新时间:2018-03-09
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
from tkinter import *
def run():
dic={0:'',1:'足球',2:'篮球',3:'游泳',4:'田径'}
chknum=[CheckVar1.get(),CheckVar2.get(),CheckVar3.get(),CheckVar4.get()]
s=''
for i in chknum:
s =dic.get(i)
if s=='':
s='您没有选择任何爱好项目'
else:
s='您选择了' s
lb2.config(text=s)
def all():
ch1.select()
ch2.select()
ch3.select()
ch4.select()
def invert():
ch1.toggle()
ch2.toggle()
ch3.toggle()
ch4.toggle()
def cancel():
ch1.deselect()
ch2.deselect()
ch3.deselect()
ch4.deselect()
root=Tk()
lb1=Label(root,text='请选择您的爱好项目:')
lb1.pack()
CheckVar1=IntVar()
CheckVar2=IntVar()
CheckVar3=IntVar()
CheckVar4=IntVar()
ch1=Checkbutton(root,text='足球',variable=CheckVar1,onvalue=1,offvalue=0)
ch1.pack()
ch2=Checkbutton(root,text='篮球',variable=CheckVar2,onvalue=2,offvalue=0)
ch2.pack()
ch3=Checkbutton(root,text='游泳',variable=CheckVar3,onvalue=3,offvalue=0)
ch3.pack()
ch4=Checkbutton(root,text='田径',variable=CheckVar4,onvalue=4,offvalue=0)
ch4.pack()
btninvert=Button(root,text='反选',command=invert)
btninvert.pack(side=RIGHT)
btnall=Button(root,text='全选',command=all)
btnall.pack(side=RIGHT)
btncancel=Button(root,text='重置',command=cancel)
btncancel.pack()
btn=Button(root,text='确认',command=run)
btn.pack()
lb2=Label(root,text='')
lb2.pack()
root.mainloop()