我想改变一个ttk框架的背景颜色,我查了其他的例子,但没有一个似乎工作。这是我到目前为止的代码:设置Tkinter/ttk框架的背景颜色
from Tkinter import *
import ttk
p = Tk()
p.geometry('600x350')
p.configure(bg='#334353')
gui_style = ttk.Style()
gui_style.configure('My.TButton', foreground='#334353')
gui_style.configure('My.TFrame', background='#334353')
frame = ttk.Frame(p, style='My.TFrame')
frame.grid(column=1, row=1)
ttk.Button(frame, text='test', style='My.TButton').grid(column=0, row=0)
ttk.Button(frame, text='Test 2', style='My.TButton').grid(column=3, row=3)
p.mainloop()
该窗口具有我想要的背景颜色,但该框架仍具有默认的灰色背景。有什么我需要添加不同?我希望整个窗口除了按钮是#334353的颜色。我该怎么做呢?
编辑:我附上了我的窗户看起来像。我不想要灰色。 :/(请注意,我没有足够的代表处,以明显发表图片,所以这里是我的当前窗口imgur链接:http://imgur.com/KyhbdMB
你的例子很适合我... – NorthCat
有很多关于这方面的问题。请先尝试使用[google搜索](https://www.google.com/search?q=python+tkinter+mac+os+background#q=python+tkinter+mac+os+x+background)。 – Lafexlos
你的操作系统是什么?如果您使用的是mac系统,则会出现前景/背景颜色的问题。不知道它是否仍然存在,但尝试搜索特定于mac的答案。 – Lafexlos