| Ticket UUID: | 1ff193f1e3adbd126e7d3100cc8ab83f016ef212 | |||
| Title: | ttk::scrollbar documentation: add "Horizontal/Vertical" to style name | |||
| Type: | Bug | Version: | 8.6.9 | |
| Submitter: | oehhar | Created on: | 2019-04-29 16:24:20 | |
| Subsystem: | 88. Themed Tk | Assigned To: | fvogel | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2026-10-11 12:43:17 | |
| Resolution: | Fixed | Closed By: | fvogel | |
| Closed on: | 2019-05-05 19:53:02 | |||
| Description: |
The ttk:scrollbar manual page states: "TScrollbar styling options configurable with ttk::style are:...". https://www.tcl-lang.org/man/tcl/TkCmd/ttk_scrollbar.htm Unfortunately, "TScrollbar" may not be used within styling commands. There must be a prefix "Horizontal." or "Vertical.". An alternate wording would be: "The styling options of "Vertical.TScrollbar" or "Horizontal.TScrollbar" which may be configured with ttk::style are:" This ticket is also a reminder to myself if nobody else is faster to change it. Thank you, Harald | |||
| User Comments: |
fvogel added on 2019-05-05 19:53:02:
Agreed. Now merged into core-8-6-branch and trunk. oehhar added on 2019-05-05 09:55:52: Thank you, Francois. I am sorry for the wrong information. I agree with you changes and propose to close the ticket and commit the changes. Thank you, Harald fvogel added on 2019-05-03 19:51:02: About -sliderlength for scrollbars: this is not deprecated, it simply not used at all by scrollbars. It's used by ttk::scale but not by ttk::scrollbar (despite a ScrollbarElement * is instantiated in SliderElementSize() in ttkClamTheme.c - this element is used by the ttk::scale widget). Try your script with a debugger: package require Tk ttk::style theme use clam ttk::style configure My.Vertical.TScrollbar -troughcolor yellow -sliderlength 100 pack [ttk::scrollbar .s -style My.Vertical.TScrollbar -command ".t yview"] -fill y -expand true -side right pack [text .t -yscrollcommand ".s set"] -side left -fill both -expand true .t insert 1.0 [string repeat 1\n 100] Set a breakpoint at the beginning of SliderElementSize() in ttkClamTheme.c and run the above script. The breakpoint is NOT hit. Not at initialization time, not later, never in that code. Committing documentation changes based on "suppositions" really is bad practice. The hypothesis you made that this function is used at runtime for initialization and the value of -sliderlength be overwritten later by the visible region fractional height can be checked easily (and be proved wrong). I have therefore removed this wrong information from ttk_scrollbar.n [a87c060617] About the available options for each element available in each theme, try this snippet:
# Introspect ttk options
# For each theme (availability is platform dependent), list all
# available elements and their options.
package require Tk
package require Tk
set nonEmpty 0
foreach th [ttk::style theme names] {
ttk::style theme use $th
foreach elt [ttk::style element names] {
set opts($th,$elt) [ttk::style element options $elt]
if {$opts($th,$elt) ne ""} {
incr nonEmpty
}
}
}
parray opts
array size opts
set nonEmpty
For me, on Windows Vista it spits 162 combinations (theme, element), among which 82 are non-empty, meaning: there is a list of available options for these 82 combinations (theme, element). I'm simply not going to document all those possibilities, but feel free to start a new branch and play this game. Note that styles, themes and elements must not be confused if you start such a big work, and please double-check every statement you commit. oehhar added on 2019-05-03 06:57:02: I think, documentation should be precise and complete. So investigate the options on my WIndows 10: % ttk::style theme use vista % ttk::style element options Vertical.TScrollbar.trough -orient -troughborderwidth -troughcolor -troughrelief -groovewidth % ttk::style theme use clam (bin) 5 % ttk::style element options Vertical.TScrollbar.trough -orient -background -bordercolor -troughcolor -lightcolor -darkcolor -arrowcolor -arrowsize -gripcount -sliderlength This feels like an endless story.... There are two candidates here, which are IMHO special:
About -sliderlength, I propose to:
About the currently undocumented options of the vista theme - new fun... Thank you, Harald oehhar added on 2019-05-03 06:31:26: Well, I thought, I have seen anything. Sourcecode inspection on 8.6.9 "sliderlength": Option definitionThe option is defined for sliders in ttkClamTheme.c and ttkDefaultTheme.c. Option usageThe option is used in ttkClamTheme.c to initialize the size of the slider:
static void SliderElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
ScrollbarElement *sb = elementRecord;
int length, thickness, orient;
length = thickness = SCROLLBAR_THICKNESS;
Ttk_GetOrientFromObj(NULL, sb->orientObj, &orient);
Tcl_GetIntFromObj(NULL, sb->arrowSizeObj, &thickness);
Tk_GetPixelsFromObj(NULL, tkwin, sb->sliderlengthObj, &length);
if (orient == TTK_ORIENT_VERTICAL) {
*heightPtr = length;
*widthPtr = thickness;
} else {
*heightPtr = thickness;
*widthPtr = length;
}
}
I suppose, the height initialization has no visual effect. It is later overwritten by the visible region fractional height. Here is my test script: ttk::style theme use clam ttk::style configure My.Vertical.TScrollbar -troughcolor yellow -sliderlength 100 pack [ttk::scrollbar .s -style My.Vertical.TScrollbar -command ".t yview"] -fill y -expand true -side right pack [text .t -yscrollcommand ".s set"] -side left -fill both -expand true .t insert 1.0 [string repeat 1\n 100] In consequence, "-sliderheight" might even be removed or depreciated as having no effect at all. In consequence, it is removed from the option help and the wiki page of ttk::scrollbar. I personally appreciate the option "arrowwidth", as the width of the scrollbar may be set. I find that useful for touch screen operation. Thank you, Harald fvogel added on 2019-05-02 21:47:30: >> Does anyone have a scrollbar example leveraging -sliderlength ? > I believe that option is not for scrollbars. Thank you, that was exactly my point. Since Harald committed documentation for -sliderlength in the scrollbar manpage I thought I may be mistaking... bll added on 2019-05-02 21:30:50: https://wiki.tcl-lang.org/page/Changing+Widget+Colors bll added on 2019-05-02 21:20:58: % ttk::style theme use default % ttk::style configure TScale -sliderlength 80 Here is one. I believe that option is not for scrollbars. Only 'default' it looks like. fvogel added on 2019-05-02 21:12:53: OK for -darkcolor and -lightcolor, now I see their effects, thanks. Does anyone have a scrollbar example leveraging -sliderlength ? bll added on 2019-05-02 21:02:38: -lightcolor and -darkcolor affect the border colors for clam based themes. In the case of a scrollbar, this is the border around the slider and the border around the arrow buttons. ttk::style configure Vertical.TScrollbar -lightcolor green ttk::style configure Vertical.TScrollbar -darkcolor red Care needs to be taken, some of the options are for alt based themes, some for default, some for classic, some for clam. I did not try to put an absolutely exhaustive list into the documentation, but more of what people need to use. Especially as some of these are only for the older themes. Thus no gripcount, slider width, height, etc. etc. Many themes have graphical elements that cannot be configured. fvogel added on 2019-05-02 20:49:04: Non-ignored options depend on the theme. I could see -gripcount in action with the clam theme (only). Fine. I couldn't see -sliderlength having an effect on a scrollbar with any theme. Could you provide an example of visible effect for -sliderlength? Same question for -darkcolor and -lightcolor, I couldn't see them. The wiki says these are used by the clam theme but I can't see the effect. (And once the above questions will become clear) Regarding the explanatory text you added in front of some options: shouldn't this be added in a several other pages, for consistency reasons? Indeed -darkcolor and -lightcolor are also lentioned in other ttk help pages. oehhar added on 2019-05-02 16:04:32: Thank you. Options: -gripcount and -sliderlength added including some explanatory text. For me, the documentation is ok now. Sorry, for the couple of comments and bug reports of the last days with bad quality and typing errors. I was travelling and typing in the train with random internet connection is sometimes a special experience. Thank you, Harald fvogel added on 2019-04-30 17:56:45: I have changed a bit the man page for ttk::scrollbar according to my message below, see the bugfix branch. Anything else remaining? fvogel added on 2019-04-30 14:00:25: Harald, about your last message, look at this snippet:
package require Tk
ttk::style theme use alt
pack [ttk::scrollbar .s] [ttk::scrollbar .sh -orient h]
# record initial state, this returns: raised {} {}
ttk::style configure TScrollbar -relief
ttk::style configure Vertical.TScrollbar -relief
ttk::style configure Horizontal.TScrollbar -relief
# change relief for both scrollbars
ttk::style configure TScrollbar -relief ridge
# back to initial state
ttk::style configure TScrollbar -relief raised
# change relief for V scrollbar only
ttk::style configure Vertical.TScrollbar -relief ridge
# back to initial state
ttk::style configure Vertical.TScrollbar -relief {} ; # and not "raised"
# get state, this returns: raised {} {}
ttk::style configure TScrollbar -relief
ttk::style configure Vertical.TScrollbar -relief
ttk::style configure Horizontal.TScrollbar -relief
# the second statement changes relief for H scrollbar only
# (because the V scrollbar has a more specific setting?)
ttk::style configure Vertical.TScrollbar -relief ridge
ttk::style configure TScrollbar -relief groove
# get state, this returns: groove ridge {}
ttk::style configure TScrollbar -relief
ttk::style configure Vertical.TScrollbar -relief
ttk::style configure Horizontal.TScrollbar -relief
# back to initial state
ttk::style configure TScrollbar -relief raised
ttk::style configure Vertical.TScrollbar -relief {} ; # and not "raised"
ttk::style configure Horizontal.TScrollbar -relief {} ; # and not "raised"
# Vertical.TScrollbar and Horizontal.TScrollbar are more
# specific than TScrollbar (no arrow will be green):
% ttk::style configure Horizontal.TScrollbar -arrowcolor red
% ttk::style configure Vertical.TScrollbar -arrowcolor blue
% ttk::style configure TScrollbar -arrowcolor green
Configuring TScrollbar is less specific than configuring Vertical.TScrollbar or Horizontal.TScrollbar. Tk takes the most specific config spec. fvogel added on 2019-04-30 06:02:42: OK, I have move the commits from core-8-6-branch and trunk, and have opened a specific bugfix branch since you seem to have further changes to propsoe. And I have added -arrowsize in the man pages of ttk::scrollbar and ttk::combobox (ttk::spinbox and ttk::menubutton already documented this option). What else? (I'll analyze later the comment you just added below). oehhar added on 2019-04-30 05:48:52: Unfortunately, my remark was not correct. "ttk::style layout" requires the prefix "Horizotal.". Also, a derived class requires it. But the style command works without it. Demo: First type: % ttk::style theme use alt % pack [ttk::scrollbar .s] -fill both -expand true Now enter the following to change the relief: % ttk::style configure TScrollbar -relief raised The relief is updated. So, the text might be somewhat more detailed, like: A derived class may use "Horizontal.TScrollbar" or "Verticla.Scrollbar" as follows: ttk::style configure My.Vertical.TScrollbar -arrowcolor red Thank you, Harald oehhar added on 2019-04-29 20:55:21: Thank you ! I am not sure if this is intended, but the list of options is quite incomplete. The current options are:
I tried to document the options on: https://wiki.tcl-lang.org/page/ttk%3A%3Ascrollbar I personally find the option "-arrowsize" useful to set the scrollbar width within some themes. fvogel added on 2019-04-29 20:14:16: Indeed. Now fixed in core-8-6-branch and trunk. | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki