3

I am trying to add some custom styling to a ttk.LabelFrame. My code looks like this:

root=Tk()
style = ttk.Style()
style.configure('TLabelFrame', background='SystemWindow')
style.configure('TFrame', background='SystemWindow')

The ttk.Frame styling works so I am not sure what is different here.

Edit: Also how can I style the label in the LabelFrame?

tristan957
  • 551
  • 2
  • 4
  • 14

3 Answers3

5

For anyone that views this line 2 in the code above should read style.configure('TLabelframe', background='SystemWindow'). I found a similar question here. Cheers!

Set style for Checkbutton or Labelframe in python tkinter

tristan957
  • 551
  • 2
  • 4
  • 14
1

For someone who just want to set the background color of LabelFrame, You just add your color's code( your can search on google like: grey color code you will get the code: #808080) in background="", this is my code:

frame =  LabelFrame(root, text="test", background="#808080")
frame.grid(padx=50, pady=25)
  • The OP asked about ttk.LabelFrame, not tkinter.LabelFrame..Your code will raise a _tkinter.TclError: unknown option "-foreground". – Jack Griffin Dec 17 '22 at 11:17
-2

Check all the tutorials related tkinter here. https://www.tutorialspoint.com/python/python_gui_programming.htm

Surely you will get the answer and use Place() method to position your elements in tkinter main frame

babygame0ver
  • 447
  • 4
  • 16
  • I can't seem to find any info on ttk widgets. All those are just the regular widgets. – tristan957 Jul 13 '17 at 17:27
  • link-only answers are discouraged on this site, and the use of `Place()` (I assume you mean the method `place`) is completely unrelated to what was asked. – Bryan Oakley Jul 13 '17 at 17:34
  • @BryanOakley just wanna thank you for answering my past 2 questions again. Extremely helpful – tristan957 Jul 13 '17 at 17:50