如何更改 ttk::combobox 的颜色
How to change color of ttk::combobox
我想更改 ttk::combobox 小部件的颜色。这是我的代码:
set MyBackgroundColor #00FF00
set MyForegroundColor #FF0000
font create MyFont -family Helvetica -size 12 -slant roman -weight normal
ttk::style theme use default
ttk::style configure TCombobox -font MyFont -background $MyBackgroundColor -fieldbackground $MyBackgroundColor -foreground $MyForegroundColor
option add *ComboboxPopdown.f.l.font MyFont
option add *ComboboxPopdown.f.l.background $MyBackgroundColor
option add *ComboboxPopdown.f.l.foreground $MyForegroundColor
# option add *ComboboxPopdown.f.l.selectbackground $MyBackgroundColor
# option add *ComboboxPopdown.f.l.selectforeground $MyForegroundColor
set Liste {Anton Berta Caesar}
set MyVar [lindex $Liste 0]
ttk::combobox .cb -values $Liste -textvariable MyVar -font MyFont -background $MyBackgroundColor -foreground $MyForegroundColor
pack .cb
如果我打开组合框并将鼠标移到条目上,条目将以黑色字体颜色和灰色背景颜色突出显示。是否可以更改这些颜色?
您可以使用以下选项更改弹出颜色:
option add *TCombobox*Listbox.background color
option add *TCombobox*Listbox.foreground color
option add *TCombobox*Listbox.selectBackground color
option add *TCombobox*Listbox.selectForeground color
编辑:
如果您需要更改特定弹出菜单的颜色或更改
创建组合框后的颜色:
set popdown [ttk::combobox::PopdownWindow .combo]
$popdown.f.l configure -background color
我想更改 ttk::combobox 小部件的颜色。这是我的代码:
set MyBackgroundColor #00FF00
set MyForegroundColor #FF0000
font create MyFont -family Helvetica -size 12 -slant roman -weight normal
ttk::style theme use default
ttk::style configure TCombobox -font MyFont -background $MyBackgroundColor -fieldbackground $MyBackgroundColor -foreground $MyForegroundColor
option add *ComboboxPopdown.f.l.font MyFont
option add *ComboboxPopdown.f.l.background $MyBackgroundColor
option add *ComboboxPopdown.f.l.foreground $MyForegroundColor
# option add *ComboboxPopdown.f.l.selectbackground $MyBackgroundColor
# option add *ComboboxPopdown.f.l.selectforeground $MyForegroundColor
set Liste {Anton Berta Caesar}
set MyVar [lindex $Liste 0]
ttk::combobox .cb -values $Liste -textvariable MyVar -font MyFont -background $MyBackgroundColor -foreground $MyForegroundColor
pack .cb
如果我打开组合框并将鼠标移到条目上,条目将以黑色字体颜色和灰色背景颜色突出显示。是否可以更改这些颜色?
您可以使用以下选项更改弹出颜色:
option add *TCombobox*Listbox.background color
option add *TCombobox*Listbox.foreground color
option add *TCombobox*Listbox.selectBackground color
option add *TCombobox*Listbox.selectForeground color
编辑:
如果您需要更改特定弹出菜单的颜色或更改 创建组合框后的颜色:
set popdown [ttk::combobox::PopdownWindow .combo]
$popdown.f.l configure -background color