gh-84008: Document that the LC_NUMERIC locale affects tkinter numeric widgets#152008
Open
serhiy-storchaka wants to merge 1 commit into
Open
gh-84008: Document that the LC_NUMERIC locale affects tkinter numeric widgets#152008serhiy-storchaka wants to merge 1 commit into
serhiy-storchaka wants to merge 1 commit into
Conversation
…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>
Documentation build overview
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tkinter.Spinbox,tkinter.Scaleandtkinter.ttk.Spinboxformat floating-point values according to theLC_NUMERIClocale (via Tcl'sformat, 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, andDoubleVar.get()then fails withTclError: 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.Scaleis not affected, since it stores a raw double.This documents the limitation: a note on
DoubleVardescribing it and theLC_NUMERIC='C'workaround, with cross-references from the affected widgets.🤖 Generated with Claude Code