tkinter 标签的背景颜色不会改变 (python 3.4)

Background color of tkinter label will not change (python 3.4)

我正在 python 3.4 中使用 Tkinter 制作小部件。出于某种原因,我无法更改标签的默认灰色背景颜色。标签的代码是这样的:

self.label = ttk.Label(master, text="Label Text", 
                       foreground="blue", background="yellow")

其他一切正常。我可以更改前景(文本)颜色,但是背景不会改变,无论我使用的是 label.config()、标签 ['background'] 还是其他。

如果我为 Python 2.7 编写它,我可以更改背景,但我在 3.4 中使用 Tkinter 的教程,所以这是不可取的。

此错误是由 Mac OSX 上的 'aqua' ttk 样式引起的。当设置为 'indeterminate' 模式时,它也会中断 'ttk.Progressbar'。要解决这两个问题,请在 'root = Tk()' 之后插入以下代码以更改样式 ...

style = ttk.Style()
style.theme_use('classic') # Any style other than aqua.

此解决方案由 dietrich41 发布 这里:http://www.python-forum.org/viewtopic.php?f=12&t=16212

我在 Mac 运行 Python 3.4.1.

上测试过