Tk Source Code

View Ticket
Login
Ticket UUID: b174f151bb41f1a484f3daefc112f4ff41e80879
Title: Test failures for ttk/treeview.test at a display scale above 100%
Type: Bug Version: 9.1b0, 9.1b1
Submitter: erikleunissen Created on: 2026-08-28 11:41:34
Subsystem: 88. Themed Tk Assigned To: nobody
Priority: 5 Medium Severity: Important
Status: Open Last Modified: 2026-11-20 14:35:48
Resolution: None Closed By: nobody
    Closed on:
Description:
I'm getting test failures for test file ttk/treeview.test when run under MS Windows 11.
Tk release: 9.1b0 (and the file ttk/treeview.test distributed with that release).

Please see the test output attached.

These test failures were observed when addressing ticket [900a8ec11a], but they appear
unrelated to the issue/changes there. What may be relevant in this regard is
that my Tk binaries were cross-built from Linux, using a gcc compiler (i.e. instead of MSVC).
User Comments: serhiy.storchaka added on 2026-11-20 14:33:58:

I ran the tests at display scales from 100% to 350% on X11 and on Windows. treeview.test fails 14-15 tests at 125% and 55-56 at 350%, on both. They are the tests added with TIP 740: Bbox-15.*, Yview-10.*, Xview-9.*, Identify-89.*, Drag_and_Drop-14.*, Row-8.*, Heading_Height-7.12, Focus_Ring-6.7, Current-19.5, See-46.42, Tag_Bind-79.* and Item_Events-48.6. I left them out of [deca13e833], which fixed the other test files, because this is a separate and more complex case.

Causes in the tests

  • The tests use pixels for the window size (800x250, 400x300), -rowheight and -headingheight (20), column widths (200), drag and xview positions, identify coordinates and the expected bbox results, while the fonts and the sizes in the default theme are in points. At 125% the heading is already taller than 20 pixels.
  • The helper mm converts pixels to millimeters with the physical size of the screen, so [mm 100] is always 100 pixels.
  • The expected results at 96 DPI depend on coincidences, so some tests do not test what they are meant to test and can hide bugs. For example columns_stretch sets the column widths to 200, which is the default width, so the treeview does not refit the stretchable columns; at any other width it does. The Drag_and_Drop tests in stretch mode thus check the column widths only in a state where the stretching code does not run.
  • The tests depend on the state left by earlier tests. Running only the Bbox tests (-match Bbox-15.*) fails 14 of them even at 100%. Some earlier test resets the Treeview style, so that the later tests use the indent built into the C code instead of the one of the theme.
  • cell_bbox uses .tv instead of its argument $w.

Possible bugs in Tk

  • The defaults of the column -width (200) and -minwidth (20) and the fallback indent (DEFAULT_INDENT, 20) in ttkTreeview.c are fixed pixels and do not follow the display scale, unlike the sizes in the theme. The widget options -rowheight and -headingheight, the column -width and -minwidth, and drag and xview accept only integers, not screen distances (their style counterparts and identify do).
  • The -indicatorsize of Heading and Item is in pixels (because of the SVG images of the chevrons), but its margins are in points, so the indicator does not scale like the rest of the item.


serhiy.storchaka added on 2026-09-29 15:57:06:

The failures depend on the display scaling. The tests use fonts in points but fixed pixel sizes (row height, window geometry, expected coordinates), so they only pass at 96 DPI (100%). With 125% scaling I get 14 failures on Windows 11, nearly the same as in the attached output. On Linux I get the same with Xvfb -dpi 120.

Setting tk scaling [expr {96 / 72.0}] at the start of treeview.test, and restoring it at the end, makes the tests pass on Windows at 125% and on Linux at up to 192 DPI. Tests which use a fixed row height should also use a fixed scaling.

The expected values also depend on state left by earlier tests: Style-5.10 does not restore the theme. So the Yview tests fail when run alone (-match Yview-*), even at 100%.


nemethi (claiming to be Csaba Nemethi) added on 2026-08-31 17:32:10:

I have just built Tk from the latest trunk file versions, using MSVC 2026. After setting the display scaling on my Windows 11 box to 100%, I ran the full test, without any failures. I have no gcc on Windows.


bohagan added on 2026-08-30 05:18:55:

I just reran the full test suite with Windows 7 and no failures. If I do the same for Windows 10 I get a bunch of tk failures and 48 ttk failures (notebook, progressbar, treeview). However, if I only run the ttk tests or just the treeview.test, then no failures. So it seems the tk tests aren't leaving a clean config which is causing downstream test failures. The failures seem to be concentrated in the Heading Height, Row Height, and item/cell keyboard event tests. These are all dependent on the Tk event loop updating before the check, so if something interferes with that, we would see these type of failures.


erikleunissen added on 2026-08-28 17:55:11:
Added test output for trunk checkin [b602b6d4e9], i.e. the checkin just before
the merge of branch treeview_test_improvements.

bohagan added on 2026-08-28 12:22:19:
Please test with 9.1b1 and its test file or trunk. There have been many changes since 9.1b0.

Attachments: