Question

I'm trying to change the color of a progress bar but the :

myProgressbar.configure(background="color")

It doesn't seems to work. I searched on the site, but didn't find an answer for the case of Tkinter.

Any idea ?

Thank you.

Était-ce utile?

La solution

In python 2.7, you can do the same using theme. Here is the code:-

import Tkinter as tk
import ttk as ttk
root = tk.Tk()
frame = tk.Frame(root)
frame.grid()
s = ttk.Style()
s.theme_use('clam')
s.configure("red.Horizontal.TProgressbar", foreground='red', background='red')
ttk.Progressbar(frame, style="red.Horizontal.TProgressbar", orient="horizontal", length=600,mode="determinate", maximum=4, value=1).grid(row=1, column=1)
frame.pack()
tk.mainloop()

You can take a look over this link:- How to change ttk.progressBar color in python

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top