Title: Harden ttk/tkinter GUI tests against display scaling (DPI) · Issue #153716 · python/cpython · GitHub
Open Graph Title: Harden ttk/tkinter GUI tests against display scaling (DPI) · Issue #153716 · python/cpython
X Title: Harden ttk/tkinter GUI tests against display scaling (DPI) · Issue #153716 · python/cpython
Description: Several test_ttk and test_tkinter GUI tests probe widget elements at fixed pixel coordinates (typically (5, 5)) or scan a fixed pixel range (e.g. range(5, 100, 5), range(0, 100, 10)). ttk element geometry — tab padding, the focus ring, t...
Open Graph Description: Several test_ttk and test_tkinter GUI tests probe widget elements at fixed pixel coordinates (typically (5, 5)) or scan a fixed pixel range (e.g. range(5, 100, 5), range(0, 100, 10)). ttk element g...
X Description: Several test_ttk and test_tkinter GUI tests probe widget elements at fixed pixel coordinates (typically (5, 5)) or scan a fixed pixel range (e.g. range(5, 100, 5), range(0, 100, 10)). ttk element g...
Opengraph URL: https://github.com/python/cpython/issues/153716
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Harden ttk/tkinter GUI tests against display scaling (DPI)","articleBody":"Several `test_ttk` and `test_tkinter` GUI tests probe widget elements at fixed pixel coordinates (typically `(5, 5)`) or scan a fixed pixel range (e.g. `range(5, 100, 5)`, `range(0, 100, 10)`). ttk element geometry — tab padding, the focus ring, trough insets, row height — scales with the display DPI (`tk scaling`), so a fixed pixel that lands on the intended element at a normal scaling lands on a different element, or misses it entirely, at a high DPI.\n\nThis produces two failure modes:\n\n- The test fails outright at high DPI (e.g. `NotebookTest.test_traversal` clicked `(5, 5)`, which no longer lands on a tab at scaling 2.0).\n- The test passes *by accident* — its assertion accepts `''` (the \"nothing here\" result), so it never actually exercises the behaviour it claims to (e.g. `ScaleTest.test_identify` always identified `''` at `(5, 5)`; the darwin branch of `test_traversal` asserted `identify(5, 5) == ''`).\n\nBoth are latent: they surface on Retina/HiDPI macOS (Homebrew Tk 9, scaling 2.0) and any X11 display with a high `-dpi`.\n\nFix: compute probe coordinates from the widget's own realized geometry instead of hardcoding pixels — `ttk::notebook index @x,y` for a point guaranteed to lie on a given tab, `winfo_width()/winfo_height()` centre for Entry, `Scale.coords()` for the trough, and scanning the real `winfo_height()` for Treeview rows. This makes the tests position-, theme-, platform- and scaling-agnostic, and removes the darwin coordinate special-cases.\n\nTest-only change. Affects `test_ttk` (`EntryTest.test_identify`, `NotebookTest.test_tab_identifiers`, `NotebookTest.test_traversal`, `TreeviewTest.test_tag_bind`) and `test_tkinter` (`ScaleTest.test_identify`). Verified across scaling 1–6 (DPI 72–432) on Tk 8.6.17 and 9.0.3.\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-153717\n* gh-153737\n* gh-153738\n* gh-153743\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/serhiy-storchaka","@type":"Person","name":"serhiy-storchaka"},"datePublished":"2026-07-14T19:21:58Z","url":"https://github.com/python/cpython/issues/153716"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8f92dfcd-843c-603a-c351-1762a52b2454 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8FEA:1E1E4D:3B0370:5153E3:6AECCA4E |
| html-safe-nonce | ee4a9db394fefe9e9333e10b56de33a7ed00775feff7d4d444fb0d86580cb675 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RkVBOjFFMUU0RDozQjAzNzA6NTE1M0UzOjZBRUNDQTRFIiwidmlzaXRvcl9pZCI6IjczNjc5NTYxOTEyMzAzNDc4NTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1f87bbafa0a66ff624320495805e12e0121038f198814ce65711ef1b78ea0095 |
| hovercard-subject-tag | issue:4886325438 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/153716/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6050a73e79789b7e5fcbbc6e35d8334da791f1f12e29a8ef87775601b166c79f/python/cpython/issues/153716 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6050a73e79789b7e5fcbbc6e35d8334da791f1f12e29a8ef87775601b166c79f/python/cpython/issues/153716 |
| og:image:alt | Several test_ttk and test_tkinter GUI tests probe widget elements at fixed pixel coordinates (typically (5, 5)) or scan a fixed pixel range (e.g. range(5, 100, 5), range(0, 100, 10)). ttk element g... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | serhiy-storchaka |
| hostname | github.com |
| expected-hostname | github.com |
| None | dc0b519c5798dc1150b88dc4c06a8b9634d0069218dc04e469970e76aad74016 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | db139f0bf57b59bf9a8c4abb0849924d6c6ca559 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width