当前位置:网站首页>选中按钮上色
选中按钮上色
2022-08-03 01:22:00 【东方金木】
from tkinter import Label, Tk,Listbox,StringVar,Button
from functools import partial
from click import command
main_win = Tk()
main_win.title('h')
width = 300
height = 300
main_win.geometry(f'{
width}x{
height}')
#选中的按钮上色
def get_selected_modle(e):
bindex=0
for k,v in main_win.children["!listbox"].children.items():
if e==bindex:
v.config(bg='green')
else:
v.config(bg='white')
bindex+=1
print(e)
modle_list=Listbox(main_win, bg='white', bd=10, cursor='cross', listvariable="", selectmode='single')
modle_list.pack(side="left")
for i ,name in enumerate(["m{}".format(i) for i in range(100)]):
confirm_button=Button(modle_list,text=name,command=partial(get_selected_modle,i))
confirm_button.pack(side="top")
# title_label=Label(main_win,text="model")
main_win.mainloop()
边栏推荐
猜你喜欢

图文详细解决IDEA使用Debug模式启动项目一直转圈圈跑起不来(亲测可以)

236. The binary tree in recent common ancestor

Shell脚本乘法口诀等小实验

暴力递归到动态规划 06 (剑指 Offer II 095. 最长公共子序列)

线上交流丨稀疏神经网络:实践和理论(青源Talk第23期 汪张扬)

“蔚来杯“2022牛客暑期多校训练营4 补题题解(N)

2022 开放原子全球开源峰会 | 麒麟信安携手openEuler助力开源产业繁荣发展

8 个常用的 Wireshark 使用技巧,一看就会

Violence recursion to dynamic programming 08 (pony go chess)

华为防火墙双机热备技术:HRP、VGMP、VRRP,三大技术值得一学!
随机推荐
电信业务分类
买了一瓶饮料
一个接口并发问题的模拟与复现
南瓜科学新品上线 开辟益智玩具新世界
鲲鹏devkit开发套件
2022/8/2 考试总结
OpenWRT setup ipv6 network
Day017 封装
一个人的精力
10-security登录
[NCTF2019]SQLi-1||SQL Injection
微信小程序--》条件与列表渲染以及WXSS模板样式
236. 二叉树的最近公共祖先
提高测试覆盖率的四大步骤
【MySQL —— 数据库约束】
iNFTnews | 元宇宙的潜力:一股推动社会进步的力量
粘包与拆包
Brute force recursion to dynamic programming 07 (516. Longest palindrome subsequence)
v-if条件判断及v-show
win下使用vscode+wsl2