I am using base Tk widgets which take the default colors of X11 (old-style).
However, I want to also use ttk::progressBar. I am trying to have the widget have a certain background color.
I know I can control the color of the "completed" part of the bar using ttk::style
and -background
:
set p .progressBar
ttk::style configure TProgressbar -background yellow -font fixed
ttk::progressbar $p -orient horizontal -variable progressBarValue -length 100
pack $p -padx 5 -pady 5 -fill x
set progressBarValue 20
The progress bar is displayed as follows:
However, I would like to know if it is possible to change the background color of the widget (from light grey to a different color). I am using just this widget from ttk.
Also I would like to know if it possible to display a text ("20%") or the widget provides only a progress bar without an overlapped text
That is the 'trough'. Try setting the style configuration '-troughcolor'. This is shared with the scrollbar so 'Horizontal.Progressbar.trough' is the specific full name of the element and 'Vertical.Progressbar.trough' for the vertical orientation.
You can't add a text element and get it updated by the widget. You could change the style layout to add such an element but it would have to get configured by the style as the widget has no code to update a text element. So you'll have to put a label widget in the right place.