0

I wish to change default white color of tkinter combobox to orange, and on selection to color it green. I cannot find how to target full field, I can only get font color changed.

image1

I searched forums and web, but couldn't find solution anywhere. I managed to color Listbox to orange, but not default value.

image2

Listbox background

window.option_add("*TCombobox*Listbox*Background", 'orange')

My Combobox style

ttk.Style().layout('combostyleO.TCombobox')
ttk.Style().configure('combostyleO.TCombobox', selectforeground='black', selectbackground='orange', background='green', foreground='orange', padding=4)

Combobox creation

lendersR = StringVar(window)
lendersR.set('Select lender')  # set the default option
choicesR = excel.Excel().get_resi_lenders_from_csv()
choicesR = sorted(choicesR)
lenderMenuR = ttk.Combobox(window, width=55, height=30, font="Courier 10", textvariable=lendersR, values=choicesR, style="combostyleO.TCombobox")
Aykhan Hagverdili
  • 28,141
  • 6
  • 41
  • 93
  • I think that here there is what you are looking for. https://stackoverflow.com/questions/27912250/how-to-set-the-background-color-of-a-ttk-combobox – 1966bc Mar 24 '19 at 13:58
  • thank you for this, it solved half of my problem. I applied style to all my combobox in app (there are 3). Now I need to apply green color only on combo that I changed, not to all of them. any idea how to do it? – Mitch Deli Mar 25 '19 at 07:12
  • Part of solution combostyle = ttk.Style() combostyle.theme_create('combostyle', parent='alt',settings = {'TCombobox': {'configure': {'selectbackground': 'orange', 'fieldbackground': 'orange', 'background': 'orange', }}} ) combostyle.theme_use('combostyle') – Mitch Deli Mar 25 '19 at 07:22

0 Answers0