在 Python 3 中使用 tkinter 更改单选按钮的背景颜色

Changing the background color of a radio button with tkinter in Python 3

我在 Python 3 中使用 ttk 向 GUI 添加了一些单选按钮,但它们周围有一个白色方块,与其余部分的蓝色背景不匹配界面.

我已经尝试了 background= ...foreground= ...bg= ...fg= ... 以及 ttk.Radiobutton() 中的一些其他内容。它适用于标签和其他东西......我错过了什么?

ttk 在其单选按钮上不支持 "background"、"foreground"、"font" 等参数,但它支持样式。 示例代码(python 3.4):

from tkinter import *
import tkinter.ttk as ttk


root = Tk()                         # Main window
myColor = '#40E0D0'                 # Its a light blue color
root.configure(bg=myColor)          # Setting color of main window to myColor

s = ttk.Style()                     # Creating style element
s.configure('Wild.TRadiobutton',    # First argument is the name of style. Needs to end with: .TRadiobutton
        background=myColor,         # Setting background to our specified color above
        foreground='black')         # You can define colors like this also

rb1 = ttk.Radiobutton(text = "works :)", style = 'Wild.TRadiobutton')       # Linking style with the button

rb1.pack()                          # Placing Radiobutton

root.mainloop()                     # Beginning loop