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