简体   繁体   中英

Is it possible to change the ttk.progressBar relief in python?

I have a progress-bar using this code:

s = ttk.Style()
s.theme_use('alt')
s.configure("blue.Horizontal.TProgressbar", troughcolor='#4d4d4d', background='#2f92ff', relief="flat")

Pb = ttk.Progressbar(root, style="blue.Horizontal.TProgressbar", orient ="horizontal", length=350, mode="determinate")

Pb.pack()

It currently looks like this:

在此处输入图片说明

Here's what the different reliefs look like if you're having a hard time seeing this:

在此处输入图片说明

It currently appears to be "sunken". I want it to be "flat". I've read documentation for ttk but I can't find anything specific to the progress-bar, so I'm wondering if this is even possible.

You're looking for the troughrelief option rather than relief .

Try the following:

from tkinter import ttk
import tkinter as tk

root = tk.Tk()

s = ttk.Style()
s.theme_use('alt')
s.configure('blue.Horizontal.TProgressbar',
        troughcolor  = '#4d4d4d',
        troughrelief = 'flat',
        background   = '#2f92ff')

pb = ttk.Progressbar(root,
        style  = 'blue.Horizontal.TProgressbar',
        orient = 'horizontal',
        length =  350,
        mode   = 'indeterminate')
pb.pack()
pb.start()

root.mainloop()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM