Skip to content

tkinter: Checkbutton and Radiobutton don't accept float width or height - #17011

Merged
Akuli merged 1 commit into
python:mainfrom
Akuli:tkinter-ints
Dec 4, 2026
Merged

Akuli merged 1 commit into
python:mainfrom
Akuli:tkinter-ints

Conversation

@Akuli

@Akuli Akuli commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Example:

>>> import tkinter
>>> tkinter.Checkbutton(width=12.34)
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    tkinter.Checkbutton(width=12.34)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/usr/lib/python3.13/tkinter/__init__.py", line 3203, in __init__
    Widget.__init__(self, master, 'checkbutton', cnf, kw)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/tkinter/__init__.py", line 2777, in __init__
    self.tk.call(
    ~~~~~~~~~~~~^
        (widgetName, self._w) + extra + self._options(cnf))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: expected integer but got "12.34"
>>> 

Noticed in #16964

I also deleted str. It works if the string looks like an integer, but that is more likely a mistake than intentional.

Does not affect ttk.Checkbutton and ttk.Radiobutton, those do accept floats.

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@Akuli
Akuli merged commit 6784c13 into python:main Dec 4, 2026
88 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants