New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ttk.OptionMenu radiobuttons change variable value twice #89323
Comments
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 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 The solution is to not use |
Thank you for reporting this issue (and doing your research!). I don't think we could use |
Ah yes, you're right that `command=self._callback` doesn't pass the new value like it should. Should we do something like this? for val in values:
menu.add_radiobutton(label=val,
variable=self._variable)
if self._callback:
menu.entryconfigure('last', command=lambda val=val: self._callback(val)) I don't have any experience making pull requests. I might look into it at some point but for now it would be great if you could make it. |
Thanks for the fix, E. Paine, and fhdrsdg for the report! ✨ 🍰 ✨ |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: