当前位置:网站首页>选中按钮上色
选中按钮上色
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()
边栏推荐
猜你喜欢

Greenplum database failure analysis, can not listen to the port

吴恩达深度学习deeplearning.ai——第一门课:神经网络与深度学习——第二节:神经网络基础(上)

10大领域5大过程47子过程快速记忆

LVS-NAT模式【案例实验】

Wireshark data capture and analysis of the transport layer protocol (TCP protocol)

新库上线 | CnOpenDataA股上市公司董监高信息数据

apache-activemq-5.14.1

五大靠谱的婚恋相亲APP详细特点缺点分析!

Violent recursion to dynamic programming 06 (the sword refers to Offer II 095. Longest common subsequence)

Kubernetes:(八)调度约束和故障排查
随机推荐
公司代码学习笔记
一个循环,两个循环问题的思考及复现
20、商品微服务-web层实现
投资的思考
常用工具链和虚拟环境-WSL
initramfs详解----设备文件系统
npm运行项目dependencies were not found: core-js/modules/es6.array.fill
线上交流丨稀疏神经网络:实践和理论(青源Talk第23期 汪张扬)
扩展卡尔曼滤波【转】
孩子坐不住就是不专注?猿辅导揭秘专注力的三大误区
怎么做postgrsql主备?
面试题整理1
236. 二叉树的最近公共祖先
自定义RunTimeException工具类
UVM中SVA使用指南
使用VSCode中遇到的问题及解决办法
FLIR E95 在8层楼看马路上行驶的CAR的热成像形态?
【遥控器开发基础教程5】疯壳·开源编队无人机-SPI(2.4G 双机通信)
不想当Window的Dialog不是一个好Modal,弹窗翻身记...
一个人的精力