Tk Source Code

View Ticket
Login
Ticket UUID: 72f6496b121e787ff56c431c3d8210e4c2b52b7
Title: ttk::treeview: [$w cget -selecttype] returns a one-element list, not a scalar
Type: Bug Version: 9.1b1
Submitter: serhiy.storchaka Created on: 2026-07-08 17:27:58
Subsystem: 88. Themed Tk Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-10-20 18:11:28
Resolution: Fixed Closed By: oehhar
    Closed on: 2026-07-10 11:14:56
Description:

Since [ea378fca79] (TIP 740), [$w cget -selecttype] returns a one-element list instead of the scalar that was set. The string value is unchanged (so pure-Tcl eq comparisons still work), but the internal representation is now a list, which object-preserving bindings expose as such — e.g. in tkinter tv.cget('selecttype') returns ('cell',) instead of 'cell'.

Cause: TreeviewConfigure() reads -selecttype with GetEnumSetFromObj(), whose Tcl_ListObjGetElements() shimmers the value to a list. That helper is for the multi-valued -show; -selecttype is a single choice (declared TK_OPTION_STRING_TABLE like -selectmode, typeFlags compared with ==), so it should stay scalar. This is not a designed change: the declaration, the docs ("item or cell"), and the == usage are all single-valued, and 9.0 returned a scalar (no GetEnumSetFromObj() call on selectTypeObj).

Fix — read it as a scalar index instead of a set (identical typeFlags); prepared on branch selecttype-scalar (check-in [3d0b5e1570]).

User Comments: oehhar added on 2026-07-10 11:14:56:

Thanks, Jan. Serhiy, please test and close the ticket if ok.

Thans, Harald


jan.nijtmans added on 2026-07-10 11:12:54:

Thanks for the fix! I agree that -selecttype is a scalar, so your implementation is OK. Actually, -selecttype it can be a bool (internally) as well (naming the variable 'isCell', for clarity), since the only values are 'item' and 'cell'.

See: [ee726c9a71b12f13]

I also made some more modifications using bool's internally wherever possible.

Thanks!


oehhar added on 2026-07-09 08:31:10:

Serhiy,

great work, thank you.

Yes, we on the tcl side are less strict here, as we don't see the difference between a one element list and a scalar. Nevertheless, the patch is welcomed.

Thanks for commit [3d0b5e15] in branch [selecttype-scalar].

Perhaps, Jan may review this?

Thanks for all, Harald