| Ticket UUID: | 031dfcf1ddbad11bffa15bc0c0cad0979d01d86e | |||
| Title: | ttk::treeview -anchor does not work with column #0 | |||
| Type: | Bug | Version: | core-8-6-branch | |
| Submitter: | fvogel | Created on: | 2020-07-08 22:03:40 | |
| Subsystem: | 88. Themed Tk | Assigned To: | fvogel | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2020-08-19 20:30:32 | |
| Resolution: | Fixed | Closed By: | fvogel | |
| Closed on: | 2020-08-19 20:30:32 | |||
| Description: |
ttk::treeview
package require Tk
ttk::treeview .t -columns [list "Col 1" "Col 2" "Col 3"]
for {set i 1} {$i < 6} {incr i} {
set val [list]
for {set j 1} {$j <=3} {incr j} {
lappend val "Value $j of item $i"
}
.t insert {} end -text "Item # $i" -values $val
}
pack .t -expand true -fill both
.t column #1 -anchor e ; # works
.t column #2 -anchor center ; # works
.t column #0 -anchor e ; # no effect --> WRONG!
| |||
| User Comments: |
fvogel added on 2020-08-19 20:30:32:
Plan applied through [15c3a464]. Branch then merged into core-8-6-branch ([8e52d751]) and trunk ([99d715aa]). I'm finally convinced by the removal of the focus ring of selected items in the treeview. tablelist behaves the same, and that's a strong argument for me. bll added on 2020-07-19 19:47:50: The scrollbar is a little unusual in that it has three layers, trough, thumb and grip. Most of the other widgets only have two layers. I suspect -unit is not necessary, otherwise some of the other themes would demonstrate drawing issues. Sounds like a plan. fvogel added on 2020-07-19 17:54:35: Thsnks for your testing! I'm wondering if we should remove the documentation for Also, I think we could remove all
Unless you manage to show a difference with bll added on 2020-07-18 17:52:03: Looks ok to me.
I was misremembering -border, so it seems to not be used.
I had -expand 1 -unit 1 for scrollbar thumbs,
probably copied from somewhere, but it seems
to have no effect on the thumb or the grip
(grip is set as -sticky {} ).
The plastik theme uses -unit 1 for thumbs, and again I see no difference with
or without.
If -border and -unit are not useful, should they be documented? Or be
marked as deprecated?
fvogel added on 2020-07-18 13:16:35: I have now :
All in all this makes quite some changes. Could you please test with your apps? The only visible change should be the working -column option in column #0 of treeviews, and the removal of the focus ring at that same place. Nothing else should have visibly changed, can you please confirm? bll added on 2020-07-18 01:30:07: -border, -unit, -expand are used within layouts. I don't believe they are used at the ttk level. Yes, they need documenting, but there needs to be a new manual page about the ttk layouts, border, focus rings, backgrounds, foregrounds, selections, layouts, how to adjust a layout, how to build a layout, how to use graphics within layouts, etc. -border and -unit are used in conjunction with graphics in layouts, they won't go away. Yes, my suggestion is to do away with the focus ring for treeview. It simply seems unnecessary since the selection has a color. In the ideal world, a non-focused treeview widget would have an -inactiveselectbackground like the 'text' widget does. fvogel added on 2020-07-17 23:03:06:
I have now documented the However, having investigated this, at the end of the day I think -expand is not needed, as Joe perhaps thought. Indeed, saying So documenting Regarding fvogel added on 2020-07-17 20:37:33: -border, -unit, -expand: may go away: looks like the original author wasn't sure to keep this. But nowadays, after years of ttk in the core and Joe having left anyway, I believe we should document those, since they are used (and work) in ttk. fvogel added on 2020-07-17 20:23:52: Oh yeah, of course there is no problem when the focus ring is entirely removed. Are you suggesting we do that? If so, let's do it rather here than with Apropos Back to the focus ring topic: what is the rest of the world doing? Do other treeview widgets, e.g. tablelist or treectrl, have a focus ring displayed on the selected row item? About bll added on 2020-07-17 14:22:53: Ok. Apparently it is not a windows thing.
I don't know why the color can't be changed on windows, but
removing the focus ring entirely works:
ttk::style layout Item {
Treeitem.padding -sticky nswe -children {
Treeitem.indicator -side left -sticky {}
Treeitem.image -side left -sticky {}
Treeitem.text -side left -sticky {}
}
}
bll added on 2020-07-17 13:56:59: Forgot...
% ttk::style layout Item
Treeitem.padding -sticky nswe -children {Treeitem.indicator -side left -sticky {} Treeitem.image -side left -sticky {} Treeitem.focus -side left -sticky {} -children {Treeitem.text -side left -sticky {}}}
That's on Linux.
ttk::style configure Item \
-focuscolor [dict get [ttk::style map Treeview -background] selected]
This resolves the issue on Linux, testing on Windows.
Does not resolve the issue on Windows. From the windows treeview documentation,
I did not see anything to set the focus ring color.
bll added on 2020-07-17 13:18:06: Testing on windows...
% ttk::style layout Treeview
Treeview.field -sticky nswe -border 1 -children {Treeview.padding -sticky nswe -children {Treeview.treearea -sticky nswe}}
The focus ring is not part of Tk. It's a windows thing.
Unless the color can be changed, there's probably not much that can be done
about it.
bll added on 2020-07-17 00:45:06: Ex 3: https://tkdocs.com/images/w_treeview_all.png Ex 4: https://static.packt-cdn.com/products/9781788622301/graphics/8d5c945d-a738-4d5a-afa2-3c9f85d751cc.png bll added on 2020-07-17 00:33:18: Well, those links didn't work. bll added on 2020-07-17 00:30:58:
Even in that first example, the reddish colored focus ring is not needed, as the selection color indicates which item is selected. I have not tested on windows, but my expectations are like this: Where the selection color covers the entire line. I actually don't know how that first example only has a background that only covers a partial line. In this example, you can see how the focus ring is just a distraction: fvogel added on 2020-07-16 22:06:42: Hmmm, Im' not so sure that the focus ring no longer fitting the text size can be ignored as a problem. See this example for instance. Granted, there are counterexamples to this as well, where the focus ring is large. That said, I have now spent some fair amount if time trying to avoid enlarging the focus ring and my conclusion is that it's just not possible without changing the ttk generic layout and drawing code quite a bit. Indeed, the treeview first places the layout, and then draws it. The sequence of things is as follows: 1. Placement (computation of element sizes and parcels, that is the layout)
2. Drawing
So in our use case we want the focus ring to be the size of the text it encloses, and not more. We also want this group (focus, text) to be movable through the -anchor column option of the treeview. Therefore no TTK_STICK_* flag must be given to the 'focus' element (otherwise the focus ring would enlarge to the size of the cavity when drawn). For a 'focus' Ttk Treeitem element with TTK_EXPAND flag only, the parcel allocated in I don't know how to change this. Instead I'm now leaning toward documenting that the -anchor option has no effect on column #0. bll added on 2020-07-08 22:36:02: I vote as not a problem. I'm not even sure why treeview has a focus ring, it's not needed. fvogel added on 2020-07-08 22:14:08: I have proposed a fix, see [477e403be7]. The The However the focus ring of the selected item is now the size of the large parcel instead of fitting the text size closely as before the fix. Is this a problem or is it not? | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki