Sebastian Hoelzl
Sebastian Hoelzl

Reputation: 363

Python 2.7: How to change color of the ttk.Checkbutton label?

I want to change the color of the label of a ttk.Checkbutton widget.

From my understanding of the tkdocs I tought this code should work:

# -*- coding: utf-8 -*-                                                         

import ttk                                                                      
import Tkinter as tk                                                            

r = tk.Tk()                                                                     
s = ttk.Style()                                                                 
s.configure('Red.TCheckbutton.label', foreground='red')                         
cb = ttk.Checkbutton(master=r, style='Red.TCheckbutton', text='Test')           
cb.pack()                                                                       
r.mainloop()

But it produces a default black label.

What am I doing wrong?

Thanks Sebastian

Upvotes: 1

Views: 3042

Answers (1)

Nae
Nae

Reputation: 15335

You have an invalid style name. Replace:

s.configure('Red.TCheckbutton.label', foreground='red')

with:

s.configure('Red.TCheckbutton', foreground='red')

Upvotes: 1

Related Questions