]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-84008: Document that the LC_NUMERIC locale affects tkinter numeric widgets...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 24 Jun 2026 06:36:53 +0000 (08:36 +0200)
committerGitHub <noreply@github.com>
Wed, 24 Jun 2026 06:36:53 +0000 (06:36 +0000)
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 ee78d4323c174d0281fef5e04e965cda4c46eeb7)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Doc/library/tkinter.rst
Doc/library/tkinter.ttk.rst

index 6e4fdc65916495cd554ac905ee54d09317eb7fe0..b65596195e4c482d35a719a1ffb990d3ad560c5d 100644 (file)
@@ -4838,6 +4838,9 @@ Widget classes
    dropped; *from* is spelled ``from_`` because :keyword:`from` is a Python
    keyword.
 
+   With a non-integer *resolution*, see :ref:`numeric values and the locale
+   <tkinter-numeric-locale>`.
+
    .. method:: get()
 
       Return the current value of the scale.
@@ -4936,6 +4939,9 @@ Widget classes
    text.
    Inherits from :class:`Widget` and :class:`XView`.
 
+   With a non-integer *increment*, see :ref:`numeric values and the locale
+   <tkinter-numeric-locale>`.
+
    Many of the methods take an *index* argument identifying a character in the
    spinbox's string.
    As described in the Tk ``spinbox`` manual page, *index* may be a numeric
@@ -5761,6 +5767,18 @@ Variable classes
 
       Return the value of the variable as a :class:`float`.
 
+   .. _tkinter-numeric-locale:
+
+   .. note::
+
+      A floating-point value is always parsed with a period (``.``) as the
+      decimal separator, but :class:`Spinbox`, :class:`Scale` and
+      :class:`ttk.Spinbox <tkinter.ttk.Spinbox>` format it according to the
+      ``LC_NUMERIC`` locale.  Under a locale that uses a comma they produce a
+      value that :meth:`get` cannot read, raising :exc:`TclError`.  Set
+      ``LC_NUMERIC`` to a locale that uses a period (such as ``'C'``) to avoid
+      this.
+
 
 .. class:: BooleanVar(master=None, value=None, name=None)
 
index c0e7472cbce2f26c6802c861b2e956855631505f..d592b482f422002c807f15a96b5903701d20a3aa 100644 (file)
@@ -465,6 +465,9 @@ ttk.Spinbox
 
 .. class:: Spinbox
 
+   With a non-integer increment, see :ref:`numeric values and the locale
+   <tkinter-numeric-locale>`.
+
    .. versionadded:: 3.8
 
    .. method:: get()