简体   繁体   中英

How to change color of the option window in combobox using ttk.style?

I want to change the background colors of combobox so I used the theme style method,

combostyle = ttk.Style()
combostyle.theme_create('combostyle', parent = 'alt',
    settings = {
        'TCombobox': {
            'configure': {
                'fieldbackground': '#313131',
                'foreground':'#FFFFFF',
                'selectbackground':'',
                'selectforeground':'#FFFFFF',
                'bordercolor':'white',
                'background': '' }
                }
            }
        )
combostyle.theme_use('combostyle')
modechoices=ttk.Combobox(frame,values=["A","B","C"], background="black", foreground="white", width=50, state="readonly")
modechoices.place(x=20, y=250)

I am able to change some parameters but I want to change the select color and option menu color (listbox bgcolor). I have found some parameters in Changing Wiget Colors , but don't know which parameter will change the part I want截屏

Is it possible to change those colors?

I got the fix, just use the option_add() method

frame.option_add("*TCombobox*Listbox*Foreground", 'white')
frame.option_add("*TCombobox*Listbox*Background", 'black')

Result:

结果

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM