Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug or feature in ttk::treeview?

218 views
Skip to first unread message

Torsten Berg

unread,
Aug 17, 2012, 3:51:55 AM8/17/12
to
Hi,

try the following:

# make a treeview:
ttk::treeview .t -columns {test}
.t heading test -text test
pack .t
# insert a value into the column:
.t insert {} end -values 12
# remove the column:
.t configure -columns {}
# insert another column:
.t configure -columns {anothertest}

Now, the value 12 inserted into the column 'test' will reappear in the new column 'anothertest' although it never was intended for that one.

Is this an intended feature, or a bug?

Regards, Torsten

Arjen Markus

unread,
Aug 17, 2012, 5:11:01 AM8/17/12
to
Op vrijdag 17 augustus 2012 09:51:55 UTC+2 schreef Torsten Berg het volgende:
This actually happens for any (well, three at least) number of rows you add
before removing the columns. So, the act of removing all columns does not make
the row data go away.

Regards,

Arjen

Joe English

unread,
Aug 20, 2012, 1:46:44 PM8/20/12
to
Torsten Berg wrote:
> # make a treeview:
> ttk::treeview .t -columns {test}
> [...]
> # insert a value into the column:
> .t insert {} end -values 12
> # remove the column:
> .t configure -columns {}
> # insert another column:
> .t configure -columns {anothertest}
>
> Now, the value 12 inserted into the column 'test' will reappear
> in the new column 'anothertest' although it never was intended
> for that one.
>
> Is this an intended feature, or a bug?

This is a misfeature.

The "-columns" option should be treated as read-only. Set it
at widget creation time and do not ever change it. Changing
-columns after data has been added to the tree leads to
counterintuitive inconsistencies like the above.

You probably want to use "-displaycolumns" instead.

(In fact "-columns" initially was a read-only option,
and was only made modifiable at the request of an early
adopter. In retrospect he was probably looking for
"-displaycolumns" as well.)


--Joe English

Torsten Berg

unread,
Aug 30, 2012, 1:40:53 PM8/30/12
to
Thanks, Joe, for the explanation. Using -displaycolumns helped solving my problem partly. But I have still the issue, that the user needs to dynamically add columns to the table. So I assume it is safe to add columns later (i.e. after widget creation time), as long as I do not remove and recreate them and just hide them (using -displaycolumns), when not used. And, of course, make sure, the columns have unique identifiers/headings.

Torsten

Torsten Berg

unread,
Sep 13, 2012, 6:17:14 AM9/13/12
to
I am using Mac OS Versions 10.7 and 10.8 together with Tcl 8.5 and 8.6 and I see that it does not work to change the -anchor of a heading, so

$treeview heading 0 -anchor -e

does not do anything. The heading always stays centered. I checked on Windows and there it worked. Is this a Mac limitation or a bug?

Also, when I pack the treeview, I always have some space on the left and even more on the right of the treeview, but I cannot really get rid of it. See this picure (http://picpaste.com/treeview.png) coming from this code:

% ttk::treeview .t
% pack .t
% . configure -background yellow

I colored the background yellow, then it is easier to see. I can reduce a bit of that "white space" with the ttk::style statement from wiki page http://wiki.tcl.tk/ttk::treeview

ttk::style layout Treeview {
Entry.field -sticky news -border 2 -children {
Treeview.padding -sticky news -children {
Treeview.treearea -sticky news
}
}
}

but it will not go away. Any ideas?

Thanks, Torsten
0 new messages