失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > html给下拉菜单设置背景色 如何更改下拉菜单活动背景的颜色(即。tk.列表框)在一个tt

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

时间:2022-07-19 23:10:39

相关推荐

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

下面的代码创建一个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=bobox(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方法,但只能更改列表框背景。在

发行日期:

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

如果觉得《html给下拉菜单设置背景色 如何更改下拉菜单活动背景的颜色(即。tk.列表框)在一个tt》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。