我在使用ttk在Python 3中处理的GUI中添加了一些单选按钮,但是它们周围有一个白色正方形,与其他GUI的蓝色背景不匹配。
我试过background= ...
,foreground= ...
,bg= ...
,fg= ...
,和一些其他的东西ttk.Radiobutton()
。它可以很好地与标签和其他东西配合使用...我想念什么?
ttk在其Radiobutton上不支持诸如“ 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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句