I'm trying to modify a ttk.Labelframe borderwidth so it is thicker, just as shown below.
On the left the default thickness, on the right the thicker border i want.
I tried styles such as:
mystyle = ttk.Style()
mystyle.configure('MyStyle.TLabelframe.Label', font=('courier', 35, 'bold'))
mystyle.configure('MyStyle.TLabelframe.border', borderwidth = 10)
lblframe = ttk.Labelframe(root, text = "Label frame", style = 'MyStyle.TLabelframe')
But, the borderwidth keeps the same.
CodePudding user response:
The borderwidth option is under TLabelframe class instead of TLabelframe.border. Also you need to change the relief option to solid to have the result in the image.
Note that not all themes support changing the border width, so try selecting other theme.
Below example works in my Windows 7:
mystyle.theme_use('alt') # choose other theme
mystyle.configure('MyStyle.TLabelframe', borderwidth=10, relief='solid', labelmargins=20)
mystyle.configure('MyStyle.TLabelframe.Label', font=('courier', 35, 'bold'))
Also note that borderwidth and relief can be set when creating the Labelframe widget as well:
lblframe = ttk.Labelframe(root, text="Label frame", borderwidth=5, relief='solid', style='MyStyle.TLabelframe')

