Gobhniu Gobhniu - 22 days ago 8
Python Question

Apply a style with ttk?

So I am trying to apply a simple style to a labelframe widget with the following code:

import sys
if sys.version_info[0] == 2: # Just checking your Python version to import Tkinter properly.
import Tkinter as tk
import ttk as ttk
else:
import tkinter as tk
from tkinter.ttk import ttk as ttk

root = tk.Tk()
bls = ttk.Style()
bls.configure('Black.TLabelFrame', background="#222222")

dayframe = ttk.Labelframe(root, style='Black.TLabelFrame', height=200, width=150, relief=tk.SUNKEN,
text="Hello")
dayframe.grid(row=1, column=1, padx=5)
root.mainloop()


But when I run this code I get the error message: TclError: Layout Black.TLabelFrame not found

I don't understand what I am doing wrong...

Answer

Use Black.TLabelframe with lower f