Is it possible to change the menu border color in tkinter

我的未来我决定 提交于 2021-01-27 20:15:00

问题


I want to change the border color of the drop down menu items.

white theme:

Using Python 3.7 and tkinter - my GUI app offer both dark and light themes, so I change the background and foreground colors dynamically. I was able to do it for most widgets, but I did not find a way to change the border color for the drop down menu items.

Here's a sample snippet of how the file_menu is defined:

self.menubar = tk.Menu(self)
self.file_menu = tk.Menu(self.menubar, tearoff=0)
self.file_menu.add_command(label="New", image=self.mnu_16_new, compound = tk.LEFT, command=self.file_new, accelerator="Ctrl+N", underline=0)
self.file_menu.add_command(label="Open", image=self.mnu_16_opn, compound = tk.LEFT, command=self.file_open, accelerator="Ctrl+O", underline=0)        

and here how I change the menu items colors (self.all_menubars is a list of all the menu items including the file_menu above)

for menu_item in self.all_menubars:
    menu_item.config(background=self.c_bg, foreground=self.c_fg, 
                     activebackground=self.c_sb, activeforeground=self.c_fg, 
                     selectcolor=self.c_fg, disabledforeground=sel_color)

while self.c_fg, self.c_sb, etc. are color variables.

来源:https://stackoverflow.com/questions/58678381/is-it-possible-to-change-the-menu-border-color-in-tkinter

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