1

I'm having trouble with changing the background color of tkinter's option menus. When I say background, I am not talking about the color of the option menu, but the color of its actual background. My tkinter window's background is gray, so when I add an option menu, it is surrounded by a few wite pixels. This doesn't happen with button or anything else that I'm aware of. Is there a way to fix this ?

Here is an image of the problem:

jizhihaoSAMA
  • 12,336
  • 9
  • 27
  • 49
Vynokris
  • 31
  • 1
  • 6

2 Answers2

1

This can be done quite simply by

root.configure(background='black')

Assuming root is the name of your window.

This question has been asked and answered before here on stackoverflow. Please, try searching the site before asking for future questions, if you still can't find the answer, go ahead and post. :-)

Havard Kleven
  • 422
  • 6
  • 19
  • Actually this would only change the background color of my tkinter window (which is already gray), not the area around the menus (which is white right now). But I figured it out as I said in my comment, it had to do with the menu's hilightthickness parameter. – Vynokris Jul 03 '20 at 10:49
  • I see, my bad. Thought it was what you were after. Glad to hear you figured out a solution – Havard Kleven Jul 03 '20 at 11:00
1

Okay everyone I found out how to do it by printing the option menu's config and looking through all the parameters. Turns out I had to add this:

<widget ref>.config(bg = "gray", highlightthickness = 0)
Vynokris
  • 31
  • 1
  • 6