0
我在使用ttk的Python 3中添加了一些单选按钮,但是它们周围有一个白色方块,它们与GUI其余部分的蓝色背景。用tkinter在Python 3中更改单选按钮的背景颜色
我试过'background =','foreground =','bg =','fg =',还有其他一些东西在ttk.Radiobutton()中。它适用于标签和其他东西...我错过了什么?
我在使用ttk的Python 3中添加了一些单选按钮,但是它们周围有一个白色方块,它们与GUI其余部分的蓝色背景。用tkinter在Python 3中更改单选按钮的背景颜色
我试过'background =','foreground =','bg =','fg =',还有其他一些东西在ttk.Radiobutton()中。它适用于标签和其他东西...我错过了什么?
ttk在其Radiobutton上不支持诸如“背景”,“前景”,“字体”等参数,但它支持样式。 示例代码(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
工程就像一个魅力。谢谢! –