Version 8 of ttk::progressbar

Updated 2011-05-24 00:28:10 by RLE

Ttk's progressbar widget.

http://www.tcl.tk/man/tcl8.5/TkCmd/ttk_progressbar.htm

  Bar color

D. McC 2008 Mar 26: Can anyone here provide a quick tip on how to change the foreground color of the progressbar from the blah blue-gray default to a color of the programmer's choice?

MG I'm not 100% sure if this is the right way, but it seems to work for me when using the "alt" theme.

  ttk::style configure TProgressbar -background $color

ttk::style

---

HaO 2011-05-23 Thread on clt 'How to change ttk::progressbar color? ' about bar color in vista.

Native Themes may not follow options that other themes have

(Kevin Walzer): On Windows and OS X, some ttk widget options cannot be configured because they are controlled by the underlying native theme engine. Progress bar colors cannot be changed on the Mac/Aqua, and I believe the same is true for Windows.

Windows Vista Widgets have a state which changes the color

(Georgios Petasis) Actually, under windows there is a limited selection of colours, as the progress bars can have a state (normal, error, paused, partial).

The trick is to use PP_FILL (5) and PP_FILLVERT (6), instead of PP_CHUNK (3) and PP_CHUNKVERT (4) that are used currently by ttk.

I don't know if they are supported by XP (I don't have an XP machine to check), but for Vista & 7 works.

In fact, since the vista theme is implemented in tcl, it can be easily tweaked (file vistaTheme.tcl):

ttk::style element create Horizontal.Progressbar.pbar vsapi \
    PROGRESS 5 {user3 2 user2 3 user1 4 {} 1} -padding 8
ttk::style element create Vertical.Progressbar.pbar vsapi \
    PROGRESS 6 {user3 2 user2 3 user1 4 {} 1} -padding 8

(I just added 5 & 6 part ids instead of 4 & 4 (was this 4 on horizontal an error instead of 3?), and I assigned the error state to user3, the paused to user2, and partial to user1.

With these changes, the following code:

package require Tk
for {set i 1} {$i < 6} {incr i} {
   pack [ttk::progressbar .$i -length 400] -fill x -expand 1 -padx 4
-pady 10
   .$i configure -value [expr $i*20]

}

.1 state user1
.2 state user2
.3 state user3

gives the following visual effect under windows 7:

http://www.ellogon.org/~petasis/tcl/Images/TtkProgressModes.png

(error is red, paused is yellow, partial is blue, and the normal one is green).

Perhaps we want to add similar support to ttk?

I forgot to mention that I found this info here: [L1 ]

(It has all the states for all parts).