]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-84008: Document that the LC_NUMERIC locale affects tkinter numeric widgets (GH...
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 24 Jun 2026 06:30:17 +0000 (09:30 +0300)
committerGitHub <noreply@github.com>
Wed, 24 Jun 2026 06:30:17 +0000 (09:30 +0300)
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>
Doc/library/tkinter.rst
Doc/library/tkinter.ttk.rst

index cee84d67668a84ca0b2885a8241b0807def03f8d..75ddc3da08a5ce5883fc68b9dfc7e15433651ea7 100644 (file)
@@ -5042,6 +5042,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.
@@ -5140,6 +5143,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
@@ -6028,6 +6034,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 b375b6908679de39af4dc0e94a5712af8270211a..ef7bbd130fb8883c212b6a882862eb16b00e64ff 100644 (file)
@@ -463,6 +463,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()