Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 478
david_p Avatar asked Jul 28 '13 20:07

david_p


1 Answers

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()
like image 170
BANZ111 Avatar answered Sep 21 '22 04:09

BANZ111