Skip to content

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

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:tkinter-doublevar-locale-note
Open

gh-84008: Document that the LC_NUMERIC locale affects tkinter numeric widgets#152008
serhiy-storchaka wants to merge 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review docs Documentation in the Doc dir 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 skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant