Fix blurry Tkinter applications on Windows 10/11 high-DPI displays
Project description
tkinter-unblur
Note:
hdpitkinterhas been reborn astkinter-unblurwith modern features. See migration guide.
Fix blurry Tkinter applications on Windows 10/11 high-DPI displays.
The Problem
Tkinter applications look blurry and pixelated on modern high-resolution displays with scaling enabled (125%, 150%, 200%, etc.). This is because Tkinter is not DPI-aware by default on Windows.
The Solution
# Before (blurry)
from tkinter import Tk
# After (crystal clear)
from tkinter_unblur import Tk
That's it. One import change, and your Tkinter app renders sharply.
Visual Comparison
Left: Standard Tkinter (blurry) | Right: tkinter-unblur (sharp)
Installation
pip install tkinter-unblur
Usage
from tkinter_unblur import Tk
root = Tk()
root.title("My App")
root.geometry("800x600")
root.mainloop()
That's all you need! For advanced usage, see API Reference.
API Reference
Tk Class
A drop-in replacement for tkinter.Tk with DPI awareness.
Attributes
dpi_x: int | None- Horizontal DPI (96 = 100% scaling)dpi_y: int | None- Vertical DPI (96 = 100% scaling)dpi_scaling: float- Scaling factor (1.0 = 100%, 1.5 = 150%)
Example:
root = Tk()
print(f"DPI: {root.dpi_x}x{root.dpi_y}")
print(f"Scaling: {root.dpi_scaling:.0%}") # e.g., "Scaling: 150%"
Methods
scale_value(value: int) -> int
Scale a numeric value by the DPI factor.
Example:
from tkinter import Label
root = Tk()
# Scale font size to maintain physical size across different DPI settings
label = Label(root, text="Hello", font=("Arial", root.scale_value(12)))
scale_geometry(geometry: str) -> str
Scale a geometry string ("WxH+X+Y") by the DPI factor.
Example:
root = Tk()
# Scale window geometry (width x height + x + y)
root.geometry(root.scale_geometry("800x600+100+50"))
Exceptions
TkinterUnblurError- Base exceptionUnsupportedPlatformError- Platform doesn't support DPI awarenessDPIDetectionError- DPI detection failed
How It Works
On Windows, this library:
- Calls
SetProcessDpiAwareness(1)to enable system DPI awareness - Queries the monitor's DPI using
GetDpiForMonitor - Provides scaling utilities for your application
On non-Windows platforms, the library is a simple passthrough to tkinter.Tk.
The implementation is based on this Stack Overflow answer.
Compatibility
| Platform | Status |
|---|---|
| Windows 10/11 | Full DPI awareness support |
| Linux | Passthrough (OS handles DPI) |
| macOS | Passthrough (OS handles DPI) |
| Python Version | Status |
|---|---|
| 3.9 - 3.14 | Supported |
| 3.8 | Not supported (EOL) |
Migrating from hdpitkinter
This package was formerly known as hdpitkinter. To migrate:
pip uninstall hdpitkinter
pip install tkinter-unblur
# Old
from hdpitkinter import HdpiTk
root = HdpiTk()
# New
from tkinter_unblur import Tk
root = Tk()
The HdpiTk name is still available as an alias for backwards compatibility:
from tkinter_unblur import HdpiTk # Works, but Tk is preferred
License
MIT License - see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tkinter_unblur-2.0.1.tar.gz.
File metadata
- Download URL: tkinter_unblur-2.0.1.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7f52828c0e8124f62b9ed7c84b80cc0e39834fa000318786e661b1e178c122b
|
|
| MD5 |
ada925f59a7e69e59dccd4bf45662e83
|
|
| BLAKE2b-256 |
e7c4945331755a9d15df69328e9cbdacc2537cbb3dd8bdc5affb9a809e68ddff
|
Provenance
The following attestation bundles were made for tkinter_unblur-2.0.1.tar.gz:
Publisher:
publish.yml on unlibra/tkinter-unblur
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tkinter_unblur-2.0.1.tar.gz -
Subject digest:
e7f52828c0e8124f62b9ed7c84b80cc0e39834fa000318786e661b1e178c122b - Sigstore transparency entry: 764231742
- Sigstore integration time:
-
Permalink:
unlibra/tkinter-unblur@c7060e7b3e06992879f463660745ac623bf42cda -
Branch / Tag:
refs/tags/v2.0.1 - Owner: https://github.com/unlibra
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c7060e7b3e06992879f463660745ac623bf42cda -
Trigger Event:
release
-
Statement type:
File details
Details for the file tkinter_unblur-2.0.1-py3-none-any.whl.
File metadata
- Download URL: tkinter_unblur-2.0.1-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6767b581a8c2c559ca3fc2404b85c9bf6cde763399aca43d888885e66b157bbd
|
|
| MD5 |
d300ff22accca22bd50f0848f643f02b
|
|
| BLAKE2b-256 |
04ee5ed8eee63da2db1e3a3ffbb1b500193dd823d1f7dac6355d48c4be591507
|
Provenance
The following attestation bundles were made for tkinter_unblur-2.0.1-py3-none-any.whl:
Publisher:
publish.yml on unlibra/tkinter-unblur
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tkinter_unblur-2.0.1-py3-none-any.whl -
Subject digest:
6767b581a8c2c559ca3fc2404b85c9bf6cde763399aca43d888885e66b157bbd - Sigstore transparency entry: 764231754
- Sigstore integration time:
-
Permalink:
unlibra/tkinter-unblur@c7060e7b3e06992879f463660745ac623bf42cda -
Branch / Tag:
refs/tags/v2.0.1 - Owner: https://github.com/unlibra
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c7060e7b3e06992879f463660745ac623bf42cda -
Trigger Event:
release
-
Statement type: