2

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

menu when dark theme white theme: enter image description here

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.

MSE
  • 625
  • 9
  • 19
  • I suppose you are aware of https://wiki.tcl-lang.org/page/Changing+Widget+Colors? If it isn't listed there,.there likely is no out-of-the-way solution. – Markus Nov 03 '19 at 08:49
  • 1
    @Markus: There are some more, do: `self.file_menu.config()` to see the whole `config options` – stovfl Nov 03 '19 at 11:27
  • @stovfl: can you please explain how does `self.file_menu.config()` show all the options? is there a specific IDE you're using which lists them? – MSE Nov 03 '19 at 11:30
  • @Michael: Nothing specific needed, simple do `print(.config())` – stovfl Nov 03 '19 at 11:32

0 Answers0