简体   繁体   中英

Is there a way to change the background of an option menu in tkinter?

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:

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. :-)

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)

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