Search code examples
pythontkintercustomtkinter

customtkinter - is there a way to perform validation on ComboBoxes?


You can use validate and validatecommand on Entry widgets but you can't perform them on comboboxes. Is there anyway to do so?

self.ESubject = ctk.CTkComboBox(
                self,
                values =  ["option1", "option2"],
                **_entry_options
            )
            self.ESubject.grid(row = 0, column = 1, sticky = "ew")
            self.ESubject.configure(validate = "key", validatecommand = (string_reg, '%P'))

Using this raises an error that states that 'validate' and 'validatecommand' are unsupported args. What can I do?


Solution

  • You can configure the internal entry widget instead:

    self.ESubject._entry.configure(validate="key", validatecommand=(string_reg, '%P'))