How to change the color of ttk button

前端 未结 3 1861
长发绾君心
长发绾君心 2020-12-31 05:37

I am using Python 3.x on Windows.

My problem is I want to customize a button widget of ttk by completely changing its background and foreground color.

3条回答
  •  萌比男神i
    2020-12-31 06:15

    import ttk
    
    root.style = ttk.Style()
    #root.style.theme_use("clam")
    style.configure('TButton', background='black')
    style.configure('TButton', foreground='green')
    button= ttk.Button(self, text="My background is black and my foreground is green.")
    

    works for me if you want to change all your buttons to the one you "desire", with Python 2.7 and Tkinter 8.6

提交回复
热议问题