Reputation:
First I was trying only used:
missed_list_combobox.config(foreground="red")
Then I was trying to set new style:
style_missed_combobox = tkinter.ttk.Style()
style_missed_combobox.configure("Red.TCombobox", foreground="red")
And use it after create the combobox widget.
missed_list_combobox = tkinter.ttk.Combobox(frame4, state="readonly", width=32, style="Red.TCombobox")
missed_list_combobox.grid(row=2, column=3, padx=2, sticky="w", pady=3)
But same ...it's only change the color of the top element in the combobox... not the entire dropdown elements... how can i change the color text of all the dropdown element..?
Thanks in advance, eliran
Upvotes: 1
Views: 2609
Reputation: 16169
As far as I know this is not directly possible with tkinter because we cannot acccess the combobox's listbox through the python interface. However this can be done using the underlying tcl interpreter with:
missed_list_combobox.tk.eval('[ttk::combobox::PopdownWindow %s].f.l configure -foreground red' % missed_list_combobox)
If you also want to change the background to yellow, just add -background yellow
to the above tcl command.
By the way, if you want to change the default foreground of all comboboxes' dropdown listbox, you can use
root.option_add('*TCombobox*Listbox.foreground' % frame, 'red')
but this will only apply to comboboxes created after this line (root
can be replaced by any widget)
Upvotes: 2