Reputation: 63
On Linux I want to change the Menu background color and make the relief flat. I've figured out how to do this but when the mouse hovers over the menu, the old background color with embossed relief appear.
from tkinter import *
from tkinter.ttk import *
root = Tk()
bar = Menu(root, background='red', relief='flat')
menu = Menu(bar, background='red', relief='flat')
menu.add_command(label='Open')
menu.add_command(label='Save')
menu.add_command(label='Exit')
bar.add_cascade(label='File', menu=menu)
root.config(menu=bar)
root.mainloop()
How can I change the background to blue (without emboss) when the mouse hovers over the menu?
Upvotes: 2
Views: 683
Reputation: 31
I know it's a lot of years later than the question but there must be many people who want a flat relief menu.
On Linux, you can change the background colour as @fhdrsdg mentions above (activebackground='blue', background='white'
would give you a white menu background and blue background to the selected item).
You can then make the relief flat by setting relief='flat'
or border=0
(makes the edge of the menubar and each dropdown menu flat relief) and activeborderwidth=0
(removes the raised relief from the selected menu item). This works on the menubar and dropdown menus.
bar = Menu(root, background='white',
activebackground='lightblue',
border=0, relief='flat',
activeborderwidth=0)
This doesn't remove the relief on the arrow pointing right for a cascade menu option, but it removes all other relief.
Flat relief and recoloured Tk menu on Linux
Finally, a slightly less ugly menu which fits better with the ttkthemes 'breeze' theme. I wish I'd realised this tweak years ago.
Upvotes: 1
Reputation: 10552
I think you're looking for the activebackground
option. This controls the background color when the mouse hovers. I'm not sure about the relief though. I'm seeing no difference between any of the relief options, but I'm assuming this is because I'm on Windows.
Upvotes: 1