Skip to content

gh-84008: Document that the LC_NUMERIC locale affects tkinter numeric widgets#152008

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:tkinter-doublevar-locale-note
Jun 24, 2026
Merged

gh-84008: Document that the LC_NUMERIC locale affects tkinter numeric widgets#152008
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:tkinter-doublevar-locale-note

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jun 23, 2026

Copy link
Copy Markdown
Member

tkinter.Spinbox, tkinter.Scale and tkinter.ttk.Spinbox format floating-point values according to the LC_NUMERIC locale (via Tcl's format, which uses the C library), but Tk always parses numbers with a period as the decimal separator.

Under a locale that uses a comma (for example de_DE), stepping such a widget writes a value like "0,1" into the linked variable, and DoubleVar.get() then fails with TclError: expected floating-point number but got "0,1".

This is an inherent Tcl/Tk inconsistency (locale-dependent formatting vs locale-independent parsing) that cannot be fixed cleanly in tkinter; I confirmed it is still present on Tk 8.6.17, 9.0.4 and 9.1b0. ttk.Scale is not affected, since it stores a raw double.

This documents the limitation: a note on DoubleVar describing it and the LC_NUMERIC='C' workaround, with cross-references from the affected widgets.

🤖 Generated with Claude Code

…umeric widgets

Spinbox, Scale and ttk.Spinbox format floating-point values according to
the LC_NUMERIC locale, but such values are always parsed with a period, so
a comma-decimal locale breaks DoubleVar.get().

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news labels Jun 23, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Jun 23, 2026
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 23, 2026
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33271581 | 📁 Comparing ae7f7d7 against main (5858e42)

  🔍 Preview build  

2 files changed
± library/tkinter.html
± library/tkinter.ttk.html

@serhiy-storchaka serhiy-storchaka merged commit ee78d43 into python:main Jun 24, 2026
42 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Jun 24, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@serhiy-storchaka serhiy-storchaka deleted the tkinter-doublevar-locale-note branch June 24, 2026 06:30
@bedevere-app

bedevere-app Bot commented Jun 24, 2026

Copy link
Copy Markdown

GH-152049 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 24, 2026
@bedevere-app

bedevere-app Bot commented Jun 24, 2026

Copy link
Copy Markdown

GH-152050 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jun 24, 2026
@bedevere-app

bedevere-app Bot commented Jun 24, 2026

Copy link
Copy Markdown

GH-152051 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jun 24, 2026
serhiy-storchaka added a commit that referenced this pull request Jun 24, 2026
…numeric widgets (GH-152008) (GH-152051)

Spinbox, Scale and ttk.Spinbox format floating-point values according to
the LC_NUMERIC locale, but such values are always parsed with a period, so
a comma-decimal locale breaks DoubleVar.get().
(cherry picked from commit ee78d43)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jun 24, 2026
…numeric widgets (GH-152008) (GH-152050)

Spinbox, Scale and ttk.Spinbox format floating-point values according to
the LC_NUMERIC locale, but such values are always parsed with a period, so
a comma-decimal locale breaks DoubleVar.get().
(cherry picked from commit ee78d43)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jun 24, 2026
…numeric widgets (GH-152008) (GH-152049)

Spinbox, Scale and ttk.Spinbox format floating-point values according to
the LC_NUMERIC locale, but such values are always parsed with a period, so
a comma-decimal locale breaks DoubleVar.get().
(cherry picked from commit ee78d43)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant