当前位置:网站首页>选中按钮上色
选中按钮上色
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()
边栏推荐
猜你喜欢
随机推荐
JSP第一篇 -----JSP九大内置对象(隐式对象)和四大域对象
软件定义网络实验之SDN网络简单管理及开发
PHICOMM(斐讯)N1盒子 - Armbian5.77(Debian 9)配置自动连接WIFI无线网络
【遥控器开发基础教程4】疯壳·开源编队无人机-SPI(OLED)
PHICOMM(斐讯)N1盒子 - Armbian5.77(Debian 9)基本配置
6-接口跨域处理
The Sandbox 市场平台将上线 Isla Obscura 第五期 NFT 作品集
【Swoole系列3.3】单进程管理Process
孩子坐不住就是不专注?猿辅导揭秘专注力的三大误区
“蔚来杯“2022牛客暑期多校训练营4 补题题解(N)
怎么做postgrsql主备?
LabVIEW程序框图保存为图像
一个循环,两个循环问题的思考及复现
visual studio 2012 为啥这么优秀
【7.31】代码源 - 【矩阵操作】【宝箱】【New Stone Game】【等差数列】
项目管理到底管的是什么?
iNFTnews | 元宇宙的潜力:一股推动社会进步的力量
PyCharm中常用的快捷键用法详解
一篇文章玩明白Stack-migration
Greenplum database failure analysis, can not listen to the port









