can't set background color ttk python os x using styles

不羁岁月 提交于 2020-01-03 01:54:19

问题


With this code fragment, I would expect the label to have a background color red. def createWidgets(self):

    style = ttk.Style()
    style.configure("Red.TLabel", foreground="green", background="red")

    self.label1 = ttk.Label(textvariable=self.numberArray[0][0],style="Red.TLabel")
    self.label1.pack()

I get the green foreground color but I can't change the background color. This is on OS X. I'm using ActiveState's tcl and python. The same problem occurs with Python 3.2 and 2.7


回答1:


You'll sometimes try to change an option that is supposed to exist according to element options, but it will have no effect. As an example, you can't modify the background color of a button in the "aqua" theme used by Mac OS X. While there are valid reasons for these cases, at the moment its not easy to discover them, which can make experimenting frustrating at times.

Taken from this tutorial http://www.tkdocs.com/tutorial/styles.html



来源:https://stackoverflow.com/questions/6723850/cant-set-background-color-ttk-python-os-x-using-styles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!