html给下拉菜单设置背景色,如何更改下拉菜单活动背景的颜色(即。tk.列表框)在一个ttk.组合框...
下面的代碼創建一個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方法,但只能更改列表框背景。在
發行日期:
總結
以上是生活随笔為你收集整理的html给下拉菜单设置背景色,如何更改下拉菜单活动背景的颜色(即。tk.列表框)在一个ttk.组合框...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2020-11-25博客营销及软文营销价
- 下一篇: 特殊票券