0

if Radio Button Text fg is set any color other than black, it doesn't show the selection but button works. User won't know if radio button is selected or not.

In below code, only Radioactivity selection is shown when click because text fg ='black' and for other 2 button you won't see the selection after clicking on it.

Any thoughts?

import tkinter as tk

window = tk.Tk()    
window.configure(background ='green')

def selVal():
    print("Selected Radio Button",(selection.get()))
    
   
# radioselect variable  
selection = tk.StringVar()
selection.set("lifetime")

# radioselect buttons 
lifetimeBtn = tk.Radiobutton(window, variable = selection, value = "lifetime", text = "Lifetime",fg='white',bg='green',command =selVal)
elecNoiseBtn = tk.Radiobutton(window, variable = selection, value = "electronic", text = "Electronic Noise",fg='white',bg='green',command =selVal)
radioactivityBtn = tk.Radiobutton(window, variable = selection, value = "radioactive", text = "Radioactivity",fg='black',bg='green',command =selVal)
lifetimeBtn.grid(row = 1, column = 0)
elecNoiseBtn.grid(row = 1, column = 1)
radioactivityBtn.grid(row = 1, column = 2)

window.mainloop()


Anni
  • 77
  • 7

1 Answers1

1

The problem is with white color. Any color other than white will work well and show the selection of radiobutton. Now with white color the button works same as the other color but the white mixes with the background white color so we can't see any difference in it. So you can use any color other than white.