如何修改Tkinter组件菜单栏的背景颜色?
Tkinter菜单栏背景颜色修改失效(Win10系统)
在Win10系统下,我用Tkinter创建GUI时,已经通过StackOverflow上的非Win10专用方案成功修改了窗口标题栏颜色,但菜单栏的背景颜色始终无法修改。
我尝试给Menu组件设置bg、fg、activebackground等属性,但菜单栏外观完全没有变化,还是系统默认样式。相关代码如下:
from tkinter import * import ctypes as ct root = Tk() root.title("MenuBar in GUI") root.geometry("500x500") root.config(bg="black") # These attributes are not working, menubar still remains unchanged menubar = Menu(root, bg='black', fg='cyan', activebackground="grey",activeforeground="cyan") filemenu = Menu(menubar, bg="black", fg="purple",activebackground="grey", activeforeground="cyan", tearoff=False) menubar.add_cascade(label="File", menu=filemenu) root.config(bg="black", menu=menubar) # Defining the main menu root.mainloop()
实际运行后,菜单栏的背景色、文字颜色等都没有按代码设置的生效,和窗口黑色背景形成明显反差。
内容的提问来源于stack exchange,提问作者OverRevvv
相关产品推荐
相关产品推荐

