Search code examples
python-3.xtkinterttkoptionmenu

How to edit ttk style for ttk.OptionMenu


Recently started using ttk for improving my GUI looks, but i got stuck at editing ttk.OptionMenu style. As I uderstand code below should change background of all Radiobuttons and OptionMenus. For Radiobutton (and other elements I tried) it works just fine, but OptionMenu doesnt change at all.

s = ttk.Style()
s.configure("TRadiobutton", background="grey")
s.configure("TOptionMenu", background="grey")

Solution

  • The style name for an OptionMenu is not TOptionMenu. For any widget the style name can get obtained using widget.winfo_class() and for an OptionMenu this returns TMenubutton.

    So s.configure("TMenubutton", background="red") yields:

    OptionMenu with red background