1

How can I change (on MAC + Windows) the color of the selected data?

enter image description here

I want to change the color of:

  • the text, in this case "CONMEBOL...."
  • the white background
  • the blue small button on the right

(this is on MAC)

Not sure how it will look on Windows, but are there any attributes I have to change?

exec85
  • 447
  • 1
  • 5
  • 21

1 Answers1

1

You can customize the way OptionMenus look, but probably not to the whole degree that you want. I know you can change the background color and the text, but the button on the right is platform dependent and should only change with changes made to your OS. (Though, I am not 100% on that so if anyone knows better, feel free to correct me.)

Here is a list of all the keys you can configure for OptionMenus:

  • activebackground
  • activeforeground
  • anchor
  • background
  • bd
  • bg
  • bitmap
  • borderwidth
  • cursor
  • direction
  • disabledforeground
  • fg
  • font
  • foreground
  • height
  • highlightbackground
  • highlightcolor
  • highlightthickness
  • image
  • indicatoron
  • justify
  • menu
  • padx
  • pady
  • relief
  • compound
  • state
  • takefocus
  • text
  • textvariable
  • underline
  • width
  • wraplength

You can clearly change the colors of the background and the text (foreground), but you will probably also want to to change the 'active' and 'disabled' version of them as well.
You can make these changes by listing the keywords after you create the widget by using .configure()
In example: a = OptionMenu(root, var, *items) a.configure(activebackground='yellow')

If you set indicatoron to 0, it will remove that button for you which may work for you.

You may also want to consider using a Combobox instead. (tkinter.ttk.Combobox) They usually blend in with their surroundings a little better and offer similar functionality, but they are less flexible on how you can customize their look.

Joel Toutloff
  • 464
  • 3
  • 4
  • hm none of these did it :-/ somethin like this i would liek to get: https://stackoverflow.com/questions/60949887/ttk-optionmenu-outer-border-around-the-menu – exec85 Sep 10 '20 at 20:05
  • 1
    That actually using ttk's version of OptionMenu...which is something I forgot existed. It may indeed suit your purposes a bit better. Ttk widgets have a tool called 'Style' to them where you can save a list of configurations and apply them to widgets as you choose. I suggest reading https://docs.python.org/3/library/tkinter.ttk.html as it will talk about how to make a Style, what things can be set in a style and how to apply a style to a ttk widget. – Joel Toutloff Sep 10 '20 at 21:11