pythontkinterwidgetoptionmenu

Changing the colour of the tk.optionmenu widget


I use this command to create a tk.optionmenu widget but its a grey colour and I want it to be white.

optionmenu = tk.OptionMenu(root,variable,*(variables)).place(x=375, y=175)

How do I change it to the white colour? I've tried this but it doesn't seem to work. Thanks!

optionmenu = tk.OptionMenu(root,variable,*(variables)colour="White").place(x=375, y=175)

Solution

  • You can change the background color by doing the following:

    optionmenu['menu'].config(bg='red')
    

    Or whatever color you want. You can find a list of colors here

    You can inspect further keyword arguements you can configure by doing the following:

    print(optionmenu['menu'].keys())
    

    Which will return:

    ['activebackground', 'activeborderwidth', 'activeforeground', 'background', 'bd', 'bg', 
     'borderwidth', 'cursor', 'disabledforeground', 'fg', 'font', 'foreground', 'postcommand', 
     'relief', 'selectcolor', 'takefocus', 'tearoff', 'tearoffcommand', 'title', 'type']