热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

html给下拉菜单设置背景色,如何更改下拉菜单活动背景的颜色(即。tk.列表框)在一个ttk.组合框...

下面的代码创建一个ttk.组合框小工具:importtkinter.ttkasttkdefault_values[Peter,Scotty,Walter,Scott,

下面的代码创建一个ttk.组合框小工具:import tkinter.ttk as ttk

default_values = ['Peter','Scotty','Walter','Scott','Mary','Sarah','Jane',

'Oscar','Walley','Faith','Bill','Egor','Heley']

s=ttk.Style()

s.configure( 'TCombobox', font=('Purisa', 20, 'bold'), background ='cyan',

fieldbackground='pink')

c=ttk.Combobox(values=default_values)

c.master.option_add( '*TCombobox*Listbox.background', 'yellow')

c.master.option_add( '*TCombobox*Listbox.selectbackground','red') #does not work

c.master.option_add( '*TCombobox*Listbox.selectforeground','grey') #does not work

c.master.option_add( '*TCombobox*Listbox.highlightbackground','blue') # does not work

c.master.option_add( '*TCombobox*Listbox.highlightforeground','green') #does not work

c.master.option_add( '*TCombobox*Listbox.activestyle', 'underline') #does not work

c.grid()

单击组合框向下箭头后,将出现一个包含default values的下拉菜单(它是一个tk.Listbox小部件)。当鼠标悬停在下拉菜单上时,鼠标指针下方会出现一个活动背景。我想改变这个灰色活动背景的颜色。我该怎么做?

作为dropdown menu isn't a ttk widget,它不会响应和ttk.Style()设置。我也尝试过.option_add方法,但只能更改列表框背景。在

发行日期:

Bmhaa.png



推荐阅读
author-avatar
jason2502893743
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有