How to change the colour of menu in Tkinter under windows?

旧街凉风 提交于 2019-12-13 01:59:32

问题


I'm using windows xp. I want to change menubar and labels foreground and background in TKinter. But, I'm unable to change. Can I change it in windows xp or I have to upgrade it to windows 7.

from Tkinter import *
root = Tk()

menubar = Menu(root)
menubar.add_command(label = 'Label1', command = log, background = 'Black', foreground = 'Red')

root.config(menu=menubar)
root.mainloop()

I'm able to display what I want and my code is working perfectly in Linux. But, it's not changing the color in window. Do I need to use any additional commands to make it work?


回答1:


There is nothing you can do. Tkinter uses a native menu object for the menus, which means they will have exactly the same look and feel of other windows menus.




回答2:


from Tkinter import *
def log():
        print 'in log fun'

root = Tk()

menubar = Menu(root)
menubar.add_command(label = 'Label1', command = log)

root.config(bg='red',menu=menubar)

root.mainloop()

you can config the background color, not possible to menu background color. enter image description here



来源:https://stackoverflow.com/questions/24111980/how-to-change-the-colour-of-menu-in-tkinter-under-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!