当前位置:网站首页>选中按钮上色
选中按钮上色
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()
边栏推荐
猜你喜欢
Shell脚本乘法口诀等小实验
EasyGBS播放器优化:设备通道视频播放出现跳屏问题的修复
高并发基石:多线程、守护线程、线程安全、线程同步、互斥锁,一文扫尽!...
.NET深入解析LINQ框架(四:IQueryable、IQueryProvider接口详解)
【社媒营销】Facebook速推帖子如何运作?值得吗?
全栈----跨域
SAP ABAP OData 服务如何支持修改(Update)操作试读版
优秀的 Verilog/FPGA开源项目总结及交流群
Wireshark data capture and analysis of the transport layer protocol (TCP protocol)
initramfs详解----设备文件系统
随机推荐
MATLAB绘制填充图(X轴上下两种颜色)
initramfs详解----设备文件系统
JS做一个接近无限时长的滚动条
【飞控开发高级教程2】疯壳·开源编队无人机-遥控整机代码走读、编译与烧写
常用工具链和虚拟环境-TDMGCC
SAP ABAP OData 服务如何支持修改(Update)操作试读版
2022-08-02:小红拿到了一个大立方体,该大立方体由1*1*1的小方块拼成,初始每个小方块都是白色。 小红可以每次选择一个小方块染成红色, 每次小红可能选择同一个小方块重复染色, 每次染色以后,
10-security登录
2022/8/2 考试总结
8 个常用的 Wireshark 使用技巧,一看就会
46LVS+Keepalived群集
npm运行项目dependencies were not found: core-js/modules/es6.array.fill
自己做的选择
无法启动服务 错误 193 0xc1
pytest:如何调用 pytest
Brute force recursion to dynamic programming 07 (516. Longest palindrome subsequence)
The cornerstone of high concurrency: multithreading, daemon threading, thread safety, thread synchronization, mutual exclusion lock, all in one article!...
一篇文章玩明白Stack-migration
iNFTnews | 元宇宙的潜力:一股推动社会进步的力量
[NCTF2019]SQLi-1||SQL注入