tkinter.ttk.Progressbar: How to change thickness of a horizontal bar

david_p picture david_p · Jul 28, 2013 · Viewed 10k times · Source

I am using the ttk.Progressbar in my app. I have scoured the net for an answer but no avail.

I have the following code which is working well. But I want to change the thickness of the bar.

progressbar = ttk.Progressbar(myGui, orient=HORIZONTAL,
                              length=400, mode="determinate",
                              variable=value_progress,
                              )
progressbar.pack()

I want the length to still be 400, but from the top of the bar to the bottom, I wish to decrease that so its half or less then half. (I want my bar on a diet, so to say)

But I am beating my head against the wall to figure out a solution.

Andy ideas? Thanks in advance.

Answer

BANZ111 picture BANZ111 · Aug 9, 2013

If you must use the xpnative theme or themes like it, then you will likely not have the option to change the thickness the conventional way. However if you use the default theme, you can configure the thickness with a style. There are likely other themes that let you do this as well, and if you're going to be playing around a lot with the look and feel of your program, you may wish to use these instead.

from Tkinter import *
from ttk import *

def main():
    root = Tk()
    s = Style()
    s.theme_use("default")
    s.configure("TProgressbar", thickness=50)
    pb = Progressbar(root, style="TProgressbar")
    pb.pack() 
    root.mainloop()

main()