Search code examples
pythontkinterttk

Tkk: custom style doesn't work


I'm trying to learn how to create a custom ttk style by following this documentition: http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-style-layer.html

Here is the code:

    self.style = ttk.Style()
    self.style.configure("ciao.TLabel", bg="red")
    poplabel = ttk.Label(self.root, text="ciao", style="ciao.TLabel")
    poplabel.place(x=0, y=530)

The problem is that the label style remains the default one and not the "ciao.TLabel".


Solution

  • The problem is that "bg" does not exist on ttk. Only "background" does, in fact

    self.style.configure("ciao.TLabel", background="red")
    

    works.