Ori Daniel
Ori Daniel

Reputation: 3

How Do I Change The Background Color Around Python Tkinter ttk.OptionMenu Widget? (Mac)

I am trying to make a script that lets you choose a day, then displays the day you have chosen on the tkinter window.

But when i have tried to change the background of the entire window to black, i didn't find a way to change the background color around the OptionMenu widget that lets you pick a day to black also.

This is an example to what i mean (Mac).

Here is my code:

from tkinter import *
import tkinter.ttk as ttk

root= Tk()
root.geometry('200x300')
root.configure(bg= 'black')

def selected(event):
    Label(root, text= clicked.get(), bg= 'black').pack()
    clicked.set(options[0])

options= ['Pick A Day', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']

clicked= StringVar()
clicked.set(options[0])

drop= ttk.OptionMenu(root, clicked, *options, command= selected)
drop.pack(pady= 20)

root.mainloop()

Upvotes: 0

Views: 157

Answers (2)

Нур Марс
Нур Марс

Reputation: 1

After the following line:

drop = ttk.OptionMenu(root, clicked, *options, command= selected)

You should add this:

drop.config(bg="black")
drop.pack(pady= 20)

Upvotes: 0

toyota Supra
toyota Supra

Reputation: 4543

i didn't find a way to change the background color around the OptionMenu widget that lets you pick a day to black

Add this before select(event) function.

s = ttk.Style()
s.configure("TMenubutton", background="black", foreground='white')

def selected(event):

Screenshot:

enter image description here

Upvotes: 0

Related Questions