Tk Source Code

View Ticket
Login
Ticket UUID: caacf1f082a82968ca543a5b2d25122387146b9b
Title: treeview column resizing not possible in some conditions
Type: Bug Version: core-8-6-branch
Submitter: fvogel Created on: 2019-10-27 08:41:30
Subsystem: 88. Themed Tk Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2019-11-01 21:00:25
Resolution: Fixed Closed By: fvogel
    Closed on: 2019-11-01 21:00:25
Description:
Reported by Steven when running ScidvsPc with the tip of core-8-6-branch:

Treeview column headings can't be resized. It is related to the total heading width in relation to the window width.
If the window width is shorter than the column heading widths, the headings can't be resized smaller or larger. If the window width is bigger, the headers can be resized, but only until the heading width is equal to the window width. I think this is wrong - surely resizing individual columns to a desired width should not be related to the toplevel's width.

Strange, but the demo widget (a multi column list of countries) seems to work... though it only has a couple of columns. I tried refining our -displaycolumns to see if I could narrow the case down, but can't.
One data point is - old versions (tested with [8140ebf0]) allow me to resize any column to any width. The demo widget for the broken version insists on showing at least stubs of the right-of-resized-column columns in the visible window, so something has obviously changed.
User Comments: fvogel added on 2019-11-01 21:00:25:

Fix [65bb96b4] for was wrong and isntroduced a regression in the headings de-activation. I have pushed another fix not suffering from such drawback, see [c5f9cdff], and have merged into core-8-6-branch and trunk.


fvogel added on 2019-10-28 11:49:30:
Thanks for your tests results!

I'm closing this now since I have just merged the result into core-8-6-branch and trunk.

stevenaaus added on 2019-10-28 04:20:19:
> I have fixed this in [65bb96b41c], still in the bug-ce470f20fd 

Seems ok.

I think https://core.tcl-lang.org/tk/info/ce470f20fd is an erroneous bug report.
To see why, replace the text "xxxxxxxxxxxxxxxxxxxxxxxxxx" with something longer

pack [ttk::treeview .tree -columns foo -padding 50]
.tree heading foo -text "Drag my right edge -->"
.tree insert "" end -values "Strange,butthedemowidgetamulticolumnlistofcountriesseemstowork."

bll added on 2019-10-28 03:01:34:
No width issues with this branch.
Note that I only have very simple treeview usage.  
I use the tree portion and nothing else.

updated-to:   65bb96b41cdd088ae105ebec22bf978c3cbfbe2e 2019-10-27 21:12:48 UTC
tags:         bug-ce470f20fd, bug-caacf1f082, bug-cc6c711c1e

fvogel added on 2019-10-27 21:34:12:
> In what exact 8.5 version are you seeing this not throwing the "Column ... out of range" error?

Sorry I see you already mention that 8.5.9 (carbon macOS) does not throw this error. However on my side I do see it with 8.5.9 (on Windows).

fvogel added on 2019-10-27 21:17:32:

Thanks for the feedback!

The following script allows to reproduce the error you report:

package require Tk
ttk::treeview .tree -columns {bar colA colB colC foo}
.tree heading bar -text "-bar-"
.tree heading colA -text "-colA-"
.tree heading colB -text "-colB-"
.tree heading colC -text "-colC-"
.tree heading foo -text "foo"
pack .tree -expand 1 -fill x
bind .tree <ButtonPress-3> {.tree configure -displaycolumns {bar colA colB colC}}
# and right-click on the heading of the rightmost column

I have fixed this in [65bb96b41c], still in the bug-ce470f20fd bugfix branch. Please confirm with your app.

This newly reported issue must be very old. In what exact 8.5 version are you seeing this not throwing the "Column ... out of range" error? I can see it with 8.5.16 at least.


stevenaaus added on 2019-10-27 20:18:00:
This fixes the resizing issue for scidvspc. 

But there is another fail/regression since 8.5 that seems to stretch back a while. In scidvspc, right click the *right most* column and select "Remove column". (In our app this adjusts the -displaycolumns arg to remove the last column). ttk is now throwing errors , bahaving erratically and dumping core (after a while). Carbon Wish-8.5.9 handles this action fine though.

Column #12 out of range
bad window path name ""
   while executing
"winfo toplevel $focus"

The problem exists back in my Catalina candidate wish version 8140ebf0
where it throws a more meaningfull error

Column #11 out of range
    while executing
"$State(activeWidget) heading $State(activeHeading) state !active"
    (procedure "ttk::treeview::ActivateHeading" line 6)
    invoked from within
"ttk::treeview::ActivateHeading {} {}"
    (command bound to event)

fvogel added on 2019-10-27 13:36:14:

In branch bug-ce470f20fd I have removed part of the commits that created the issue reported in this ticket, see commit [c74b6837].

This new commit restores the ability of dragging the right edge of the rightmost heading of the treeview, which was requested to be forbidden in [ce470f20fd].

After careful thinking I believe it should be restored as it was. This is also how Tablelist behaves. This new commit doesn't however exactly make [ce470f20fd] a won't fix: Some commits made when dealing with [ce470f20fd] are kept and are pertinent I think. Mainly, we are still keeping the changed behavior when at least one column is stretchable (in this case now there is no slack anymore). I believe it's best like this, we're mimicking Tablelist to the best of my knowledge, be it with or without stretchable columns, and with or without hidden columns, and whatever the width of the containing geometry manager window is.

I would be very happy to read testing results from people using the treeview (Steven, Brad, at least). Please use branch bug-ce470f20fd and report here. Thanks!


fvogel added on 2019-10-27 11:11:14:

I have removed the problematic commits [0e9cbdba] and [82b1d286] from core-8-6-branch and trunk.

Work can now go on in the original branch bug-ce470f20fd to make considerations made in [ce470f20fd], [cc6c711c1e] and in the present ticket sleep together.


fvogel added on 2019-10-27 08:59:42:

Reproducible (most likely non minimal but quickly designed) script:

package require Tk
pack [ttk::treeview .tree -columns {bar colA colB colC foo} -padding 50]
.tree heading bar -text "-bar-"
.tree heading colA -text "-colA-"
.tree heading colB -text "-colB-"
.tree heading colC -text "-colC-"
.tree heading foo -text "Drag my right edge -->"
.tree insert "" end -values xxxxxxxxxxxxxxxxxxxxxxxxxx
pack conf .tree -expand 1 -fill x

proc nostretch {} {
foreach col [.tree cget -columns] {
    .tree column $col -stretch 0
}
.tree column #0 -stretch 0
}
nostretch
wm geometry . 700x300
# now try interactive resizing


fvogel added on 2019-10-27 08:52:14:

Treeview columns resizing was changed since version [8140ebf0] when addressing tickets [ce470f20fd] and [cc6c711c1e].

If the respective fixes [0e9cbdba] and [82b1d286] of these two tickets are removed then the previous behavior is restored (but of course the above tickets resurrect).

fossil merge --backout 82b1d286
fossil merge --backout 0e9cbdba

I'll have a look at this issue. Except if the fix is easy and quick, I could remove the two commits above from the main branches in order to avoid letting that unperfect behavior change go into the upcoming 8.6.10 release.


Attachments: