Search code examples
pythonmacosoperating-systemtkinterttk

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


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


Solution

  • 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