Skip to content

Commit 9bd0199

Browse files
miss-islingtonserhiy-storchakaclaude
authored
[3.15] gh-84008: Document that the LC_NUMERIC locale affects tkinter numeric widgets (GH-152008) (GH-152049)
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 dbc9b68 commit 9bd0199

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
@@ -4903,6 +4903,9 @@ Widget classes
49034903
dropped; *from* is spelled ``from_`` because :keyword:`from` is a Python
49044904
keyword.
49054905

4906+
With a non-integer *resolution*, see :ref:`numeric values and the locale
4907+
<tkinter-numeric-locale>`.
4908+
49064909
.. method:: get()
49074910

49084911
Return the current value of the scale.
@@ -5001,6 +5004,9 @@ Widget classes
50015004
text.
50025005
Inherits from :class:`Widget` and :class:`XView`.
50035006

5007+
With a non-integer *increment*, see :ref:`numeric values and the locale
5008+
<tkinter-numeric-locale>`.
5009+
50045010
Many of the methods take an *index* argument identifying a character in the
50055011
spinbox's string.
50065012
As described in the Tk ``spinbox`` manual page, *index* may be a numeric
@@ -5844,6 +5850,18 @@ Variable classes
58445850

58455851
Return the value of the variable as a :class:`float`.
58465852

5853+
.. _tkinter-numeric-locale:
5854+
5855+
.. note::
5856+
5857+
A floating-point value is always parsed with a period (``.``) as the
5858+
decimal separator, but :class:`Spinbox`, :class:`Scale` and
5859+
:class:`ttk.Spinbox <tkinter.ttk.Spinbox>` format it according to the
5860+
``LC_NUMERIC`` locale. Under a locale that uses a comma they produce a
5861+
value that :meth:`get` cannot read, raising :exc:`TclError`. Set
5862+
``LC_NUMERIC`` to a locale that uses a period (such as ``'C'``) to avoid
5863+
this.
5864+
58475865

58485866
.. class:: BooleanVar(master=None, value=None, name=None)
58495867

Doc/library/tkinter.ttk.rst

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

464464
.. class:: Spinbox
465465

466+
With a non-integer increment, see :ref:`numeric values and the locale
467+
<tkinter-numeric-locale>`.
468+
466469
.. versionadded:: 3.8
467470

468471
.. method:: get()

0 commit comments

Comments
 (0)