This problem nearly makes me craze. I am a new beginner and without knowledge of tck/tk. I have done carefully search on the internet but haven't found a good solution.
For example, I created a label frame using
import tkinter as tk
from tkinter import ttk
newBT = ttk.LabelFrame(width=100, height=100)
Then I need to set the frame style. There is foreground for tk.LabelFrame. However, I didn't find such style option for ttk.LabelFrame on NMT and tck/tk reference. Then I have to guess, like following
s = ttk.Style()
s.configure('TLabelframe', foreground='red')
But this doesn't work, the right thing is
s.configure('TLabelframe.Label', foreground='red')
So, my question is, how can I find out all the style options a ttk widget has. Is there some function like
s.getAllOptions('TLabelframe')
and then the output is something like
['background', 'foreground', 'padding', 'border', ...]
Thanks!
Building on SunBear's script:
Prints the config options as well as the layout tree.
I found your question interesting as I had asked myself the same question but have not found time to address it until now. I have written a function called
stylename_elements_options(stylename)
to do just this. Sharing it here. Hope it can benefit you (although it is 6 months late) and any tkinter users asking the same question.Script:
The issue is that if you really want to control a style in detail you need to use the layout. So first identify the widget class using:
Then use the command
Finally change what you want:
This made the trick for me and finally provides me a way to control my ttk widget!!!
Luca