Index: doc/ttk_progressbar.n ================================================================== --- doc/ttk_progressbar.n +++ doc/ttk_progressbar.n @@ -22,11 +22,12 @@ .PP If the value of \fB-orient\fR is \fBhorizontal\fR a text string can be displayed inside the progressbar. This string can be configured using the \fB-anchor\fR, \fB-font\fR, \fB-foreground\fR, \fB-justify\fR, \fB-text\fR and \fB-wraplength\fR options. If the value of \fB-orient\fR -is \fBvertical\fR then these options are ignored. +is \fBvertical\fR then these options are ignored. When configuring +\fB-text\fR, \fB-font\fR should be configured as well. .SO ttk_widget \-anchor \-class \-cursor \-font \-foreground \-justify \-style \-takefocus \-text \-wraplength .SE Index: generic/ttk/ttkProgress.c ================================================================== --- generic/ttk/ttkProgress.c +++ generic/ttk/ttkProgress.c @@ -52,11 +52,11 @@ { {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", "w", offsetof(Progressbar,progress.anchorObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED}, {TK_OPTION_FONT, "-font", "font", "Font", - DEFAULT_FONT, offsetof(Progressbar,progress.fontObj), TCL_INDEX_NONE, + "TkDefaultFont_progressbar", offsetof(Progressbar,progress.fontObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_COLOR, "-foreground", "textColor", "TextColor", "black", offsetof(Progressbar,progress.foregroundObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0 }, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", Index: library/ttk/progress.tcl ================================================================== --- library/ttk/progress.tcl +++ library/ttk/progress.tcl @@ -1,11 +1,22 @@ # # Ttk widget set: progress bar utilities. # namespace eval ttk::progressbar { + variable Timers ;# Map: widget name -> after ID + + # Default font for -text option in progressbars: + # The size of a progressbar takes the font height into account so that when + # some -text is to be displayed it does not get cropped. The default font + # size must be very small in order to not increase the progresbar height + # to the font height when no text is displayed (which is the default). + # When some -text must be displayed then the user has to set an adequate + # font size. For more details, see ticket [8bee4b2009]. + font create TkDefaultFont_progressbar {*}[font actual TkDefaultFont] + font configure TkDefaultFont_progressbar -size -1 } # Autoincrement -- # Periodic callback procedure for autoincrement mode # ADDED tests/ttk/pb_image.svg Index: tests/ttk/pb_image.svg ================================================================== --- /dev/null +++ tests/ttk/pb_image.svg @@ -0,0 +1,76 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + Index: tests/ttk/progressbar.test ================================================================== --- tests/ttk/progressbar.test +++ tests/ttk/progressbar.test @@ -119,10 +119,26 @@ set res } -cleanup { unset res thefont destroy .p } -result {{-anchor e} {-foreground green} {-justify center} {-text {Cannot be seen}} {-wraplength 250}} + +test progressbar-3.3 {horizontal progressbar height with no -text (TIP #442) specified - Bug [8bee4b2009]} -setup { + set oldTheme [ttk::style theme use] +} -body { + ttk::style theme use default + set imga [image create photo -file [file join [file dirname [info script]] pb_image.svg] -format {svg -scale 0.8}] + ::ttk::style element create Horizontal.Progressbar.pbar image $imga + pack [ttk::progressbar .p -orient horizontal] + .p step 25 + update + expr {[winfo reqheight .p] == [image height $imga] + 2} +} -cleanup { + destroy .p + ttk::style theme use $oldTheme + # there's no way I know to undo '::ttk::style element create...' +} -result {1} test progressbar-4.1 "style command" -body { ttk::progressbar .wh ; # default is -orient horizontal ttk::progressbar .wv -orient vertical list [.wh cget -style] [.wh style] [winfo class .wh]\