This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author fhdrsdg
Recipients fhdrsdg
Date 2021-09-10.07:13:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1631257980.33.0.506661911605.issue45160@roundup.psfhosted.org>
In-reply-to
Content
Found when trying to answer this SO question: https://stackoverflow.com/questions/53171384/tkinter-function-repeats-itself-twice-when-ttk-widgets-are-engaged

The ttk.OptionMenu uses radiobuttons for the dropdown menu, whereas the tkinter.OptionMenu uses commands. Both of them use `_setit` as command, presumably first used for tkinter and then copied to the ttk implementation. The `_setit` does two things: changing the associated `variable` and calling the associated callback function. This is needed for the tkinter.OptionMenu since commands don't support changing a `variable`.

However, for the ttk.OptionMenu an additional reference to the variable was added to the radiobutton following this issue: https://bugs.python.org/issue25684. This was needed to group radiobuttons, but now leads to the variable being changed twice: once by the radiobutton and once through `_setit`. When tracing the variable this leads to the tracing callback being called twice on only one change of the OptionMenu.

The solution is to not use `_setit` for the radiobutton command but instead just use `command=self._callback`
History
Date User Action Args
2021-09-10 07:13:00fhdrsdgsetrecipients: + fhdrsdg
2021-09-10 07:13:00fhdrsdgsetmessageid: <1631257980.33.0.506661911605.issue45160@roundup.psfhosted.org>
2021-09-10 07:13:00fhdrsdglinkissue45160 messages
2021-09-10 07:13:00fhdrsdgcreate