0

I have problem to change indicator color for ttk radiobutton, I have followed this answer (https://stackoverflow.com/a/48497928/17286537) but nothing works for me. The indicator color stays the same, blue and when not hovered changed into black.

I have tried changing in style.configure and search another answer. But I have not found any solutions. What I expected is when the radiobutton selected, the border and indicator color change to blue, and when not hovered, the border and indicator color stays blue. Can anyone give me a solutions and explain the behavior of the tkinter framework when comes to customization? Thank you.

Here is the code that I tried so far.

from tkinter import *
import tkinter.ttk as ttk
from PIL import Image, ImageTk

root = Tk()
root.geometry('768x570')
root.title('euy')

root_frame = Frame(root)
root_frame.pack(fill=BOTH, expand=1, padx=32)

common_fg = '#FF0'
common_bg = '#0672D9'

# style_name = rb_step2.winfo_class()
style = ttk.Style()
style.configure('C.TRadiobutton', background=common_fg,
                indicatorcolor=common_fg)
style.map('C.TRadiobutton',
          indicatorcolor=[('selected', common_bg),
                          ('pressed', '#FF0')]

          )
rb_step2 = ttk.Radiobutton(root_frame, style='C.TRadiobutton')
rb_step2.pack()

the result

enter image description here

hol'Up
  • 49
  • 3
  • 3
    See [this answer](https://stackoverflow.com/a/33292115/291641) about checkbuttons which is basically the same. As you are using Windows, your theme uses elements provided by the VSAPI theming engine so Tk cannot change the indicator. If you *must* do this, you can create an element from a Tk-drawn theme (eg 'default') and then use that in the style. There is an example answer for the [Windows scrollbar](https://stackoverflow.com/a/29583609/291641) – patthoyts May 16 '23 at 11:37
  • @patthoyts Thank you, from link that you gave, I realized which step that I missed. – hol'Up May 16 '23 at 14:24

0 Answers0