8

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...

Tiago Martins Peres
  • 14,289
  • 18
  • 86
  • 145
Gobhniu
  • 265
  • 3
  • 11
  • 3
    use `Black.TLabelframe` with lower `f` – furas Nov 17 '16 at 02:16
  • I encountered this issue too. The documentation by [nmt](http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-style-layer.html) wrote `TLabelFrame`. Recommend the typo there be correct too. – Sun Bear Feb 01 '19 at 09:20

1 Answers1

10

Use Black.TLabelframe with lower f

furas
  • 134,197
  • 12
  • 106
  • 148