Skip to content

Fix: allow CTkSwitch.configure() to accept 'onvalue' and 'offvalue' #2719

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fredmain
Copy link

@fredmain fredmain commented May 4, 2025

Description

This pull request fixes an issue in the CTkSwitch widget where the onvalue and offvalue parameters could only be set during initialization, but not via the configure() method.

Trying to use .configure(onvalue=..., offvalue=...) would raise a ValueError due to missing handling for those parameters in the method.

Reproduction

import customtkinter

root = customtkinter.CTk()
s = customtkinter.CTkSwitch(root)
s.configure(onvalue='manual', offvalue='automatic')  # 💥 ValueError before this fix
s.pack()
root.mainloop()

Fix

I added handling for onvalue and offvalue inside the configure() method of CTkSwitch, following the same pattern used for other supported keyword arguments like text, state, and variable.
Let me know if I should add test cases or adjust anything.

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.

1 participant