python 桌面开发实例-python 入门级windows示例源码(桌面应用程序)

【实例简介】

【实例截图】

0613de16265ae033a22c3b4cb36be84d.png

244cc0d57320df2c7543a734963a8c48.png

e9fdb752cd7c2e26b882974594e207c1.png

9ae9d0793224eae2d5ff03bba30c2e7e.png

754a9d32377663a2168f7b781e687e22.png

1288059b6d99ac000c309c8745119b22.png

48548f6422062b5b164ff68700f2bdfc.png

200d018fdd4648c6fd71e4e16f63cb33.png

【核心代码】

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()

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值