Skip to content

Commit 43c188d

Browse files
miss-islingtonserhiy-storchakaclaude
authored
[3.13] gh-84008: Document that the LC_NUMERIC locale affects tkinter 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>
1 parent 32546b7 commit 43c188d

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

Doc/library/tkinter.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4838,6 +4838,9 @@ Widget classes
48384838
dropped; *from* is spelled ``from_`` because :keyword:`from` is a Python
48394839
keyword.
48404840

4841+
With a non-integer *resolution*, see :ref:`numeric values and the locale
4842+
<tkinter-numeric-locale>`.
4843+
48414844
.. method:: get()
48424845

48434846
Return the current value of the scale.
@@ -4936,6 +4939,9 @@ Widget classes
49364939
text.
49374940
Inherits from :class:`Widget` and :class:`XView`.
49384941

4942+
With a non-integer *increment*, see :ref:`numeric values and the locale
4943+
<tkinter-numeric-locale>`.
4944+
49394945
Many of the methods take an *index* argument identifying a character in the
49404946
spinbox's string.
49414947
As described in the Tk ``spinbox`` manual page, *index* may be a numeric
@@ -5761,6 +5767,18 @@ Variable classes
57615767

57625768
Return the value of the variable as a :class:`float`.
57635769

5770+
.. _tkinter-numeric-locale:
5771+
5772+
.. note::
5773+
5774+
A floating-point value is always parsed with a period (``.``) as the
5775+
decimal separator, but :class:`Spinbox`, :class:`Scale` and
5776+
:class:`ttk.Spinbox <tkinter.ttk.Spinbox>` format it according to the
5777+
``LC_NUMERIC`` locale. Under a locale that uses a comma they produce a
5778+
value that :meth:`get` cannot read, raising :exc:`TclError`. Set
5779+
``LC_NUMERIC`` to a locale that uses a period (such as ``'C'``) to avoid
5780+
this.
5781+
57645782

57655783
.. class:: BooleanVar(master=None, value=None, name=None)
57665784

Doc/library/tkinter.ttk.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,9 @@ ttk.Spinbox
465465

466466
.. class:: Spinbox
467467

468+
With a non-integer increment, see :ref:`numeric values and the locale
469+
<tkinter-numeric-locale>`.
470+
468471
.. versionadded:: 3.8
469472

470473
.. method:: get()

0 commit comments

Comments
 (0)