Skip to content

Commit 59ff73a

Browse files
miss-islingtonserhiy-storchakaclaude
authored
[3.14] gh-84008: Document that the LC_NUMERIC locale affects tkinter 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>
1 parent 0ba13d3 commit 59ff73a

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
@@ -4849,6 +4849,9 @@ Widget classes
48494849
dropped; *from* is spelled ``from_`` because :keyword:`from` is a Python
48504850
keyword.
48514851

4852+
With a non-integer *resolution*, see :ref:`numeric values and the locale
4853+
<tkinter-numeric-locale>`.
4854+
48524855
.. method:: get()
48534856

48544857
Return the current value of the scale.
@@ -4947,6 +4950,9 @@ Widget classes
49474950
text.
49484951
Inherits from :class:`Widget` and :class:`XView`.
49494952

4953+
With a non-integer *increment*, see :ref:`numeric values and the locale
4954+
<tkinter-numeric-locale>`.
4955+
49504956
Many of the methods take an *index* argument identifying a character in the
49514957
spinbox's string.
49524958
As described in the Tk ``spinbox`` manual page, *index* may be a numeric
@@ -5772,6 +5778,18 @@ Variable classes
57725778

57735779
Return the value of the variable as a :class:`float`.
57745780

5781+
.. _tkinter-numeric-locale:
5782+
5783+
.. note::
5784+
5785+
A floating-point value is always parsed with a period (``.``) as the
5786+
decimal separator, but :class:`Spinbox`, :class:`Scale` and
5787+
:class:`ttk.Spinbox <tkinter.ttk.Spinbox>` format it according to the
5788+
``LC_NUMERIC`` locale. Under a locale that uses a comma they produce a
5789+
value that :meth:`get` cannot read, raising :exc:`TclError`. Set
5790+
``LC_NUMERIC`` to a locale that uses a period (such as ``'C'``) to avoid
5791+
this.
5792+
57755793

57765794
.. class:: BooleanVar(master=None, value=None, name=None)
57775795

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)