当前位置:网站首页>选中按钮上色
选中按钮上色
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()
边栏推荐
猜你喜欢
随机推荐
【深度学习】基于tensorflow的小型物体识别训练(数据集:CIFAR-10)
45部署LVS-DR群集
20、商品微服务-web层实现
WRF-Chem模式调试、运行、结果后处理等遇到的各种问题
南瓜科学新品上线 开辟益智玩具新世界
VS2010 组件列表与对应名称
开发JSP应用的基础知识
236. The binary tree in recent common ancestor
UVM中SVA使用指南
The Sandbox 市场平台将上线 Isla Obscura 第五期 NFT 作品集
常用工具链和虚拟环境-TDMGCC
11-security认证.md
flask-socketio实现websocket通信
增删改查这么多年,最后栽在MySQL的架构设计上!
麒麟信安邀您抢先看 | openEuler 志高远,开源汇智创未来-开放原子全球开源峰会欧拉分论坛最详细议程出炉
【MySQL —— 数据库约束】
嵌入式开发:嵌入式基础——’ ’和” ”的区别
apache-activemq-5.14.1
Greenplum数据库故障分析——can not listen port
PHICOMM(斐讯)N1盒子 - Armbian5.77(Debian 9)配置自动连接WIFI无线网络









