Skip to main content

tkinter-unblur

PyPI version PyPI Downloads Python versions Type checked CI License Docs

Note: hdpitkinter has been reborn as tkinter-unblur with modern features. See migration guide.

Fix blurry Tkinter applications on Windows 10/11 high-DPI displays.

Documentation · PyPI

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

Blurry vs Sharp 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: float | str) -> int

Scale a numeric value by the DPI factor.

Example:

from tkinter import Label

root = Tk()
# Tk does not scale pixel values, such as padding, so scale them yourself
label = Label(root, text="Hello", font=("Arial", 12))
label.pack(padx=root.scale_value(10), pady=root.scale_value(10))

Font sizes in points, such as ("Arial", 12), need no scaling: Tk already sizes them for the display's DPI. Scaling them again with scale_value() makes the text too large.

scale_geometry(geometry: str) -> str

Scale a geometry string by the DPI factor. It accepts every form root.geometry() accepts:

  • "WxH", such as "800x600"
  • "WxH+X+Y", such as "800x600+100+50". Each sign can be + or -, as in "800x600-100-50".
  • "+X+Y", a position only. Each sign can be + or - here too.
  • Any of these with a leading "="

The result has the same form as the input, with the signs kept. Any other string raises ValueError.

Example:

root = Tk()
root.geometry(root.scale_geometry("800x600"))          # "1200x900" at 150%
root.geometry(root.scale_geometry("800x600+100+50"))   # "1200x900+150+75" at 150%

Exceptions

  • TkinterUnblurError - Base exception
  • UnsupportedPlatformError - Reserved, not currently raised (non-Windows: dpi_scaling is 1.0)
  • DPIDetectionError - Reserved, not currently raised (on failure: warning logged, dpi_scaling is 1.0)

How It Works

On Windows, this library:

  1. Calls SetProcessDpiAwareness(1) to enable system DPI awareness, before the Tk window is created
  2. Queries the monitor's DPI using GetDpiForMonitor
  3. 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 System DPI awareness (one DPI for all monitors, see limitation)
Linux Passthrough (OS handles DPI)
macOS Passthrough (OS handles DPI)
Python Version Status
3.10 - 3.15 Supported
3.9 and earlier Not supported

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.

Metadata

Release files for tkinter-unblur 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tkinter-unblur 3.1.0
File Size Uploaded Provenance Actions
tkinter_unblur-3.1.0.tar.gz 15.6 kB With provenance Details for tkinter_unblur-3.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tkinter-unblur 3.1.0
File Interpreter ABI Platform Actions
tkinter_unblur-3.1.0-py3-none-any.whl Python 3 none any Details for tkinter_unblur-3.1.0-py3-none-any.whl

Total release size: 26.6 kB

Release files / tkinter_unblur-3.1.0.tar.gz

Download URL tkinter_unblur-3.1.0.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b8106d26b656b940ab3a99739fd4f79f86ee3e2513a1b0631732930b4522b4b5
BLAKE2b-256 checksum
How to use checksums
299fab286b0b5df4c39c88b0513c6f37db947a88b9637db067249bf796590470
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Release files / tkinter_unblur-3.1.0-py3-none-any.whl

Download URL tkinter_unblur-3.1.0-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22606f73ce59f650ad811e5b834f9fc2b57f156232a1d8a74db69c117a2c6004
BLAKE2b-256 checksum
How to use checksums
c09895bc174ba8eabe2cf1e2591d05d47c3e6ca527e23fd049c69238da6a48a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Security for tkinter-unblur 3.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tkinter_unblur-3.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page