Create the appropriate input widget.
(self, value: Any)
| 207 | CTkTooltip(self._input_widget, tooltip) |
| 208 | |
| 209 | def _create_input(self, value: Any) -> None: |
| 210 | """Create the appropriate input widget.""" |
| 211 | if self._type_hint == "bool": |
| 212 | self._value_var = ctk.BooleanVar(value=bool(value)) |
| 213 | self._input_widget = ctk.CTkSwitch( |
| 214 | self, |
| 215 | text="", |
| 216 | variable=self._value_var, |
| 217 | command=self._on_value_change, |
| 218 | fg_color=COLORS["bg_light"], |
| 219 | progress_color=COLORS["accent"], |
| 220 | button_color=COLORS["text_primary"], |
| 221 | button_hover_color=COLORS["accent_hover"], |
| 222 | ) |
| 223 | self._input_widget.grid(row=0, column=1, sticky="w", pady=5) |
| 224 | |
| 225 | elif self._type_hint == "int": |
| 226 | self._value_var = ctk.StringVar(value=str(value)) |
| 227 | self._value_var.trace_add("write", lambda *args: self._on_value_change()) |
| 228 | self._input_widget = ctk.CTkEntry( |
| 229 | self, |
| 230 | textvariable=self._value_var, |
| 231 | width=150, |
| 232 | height=32, |
| 233 | fg_color=COLORS["bg_light"], |
| 234 | border_color=COLORS["border"], |
| 235 | text_color=COLORS["text_primary"], |
| 236 | ) |
| 237 | self._input_widget.grid(row=0, column=1, sticky="w", pady=5) |
| 238 | |
| 239 | elif self._type_hint == "float": |
| 240 | self._value_var = ctk.StringVar(value=str(value)) |
| 241 | self._value_var.trace_add("write", lambda *args: self._on_value_change()) |
| 242 | self._input_widget = ctk.CTkEntry( |
| 243 | self, |
| 244 | textvariable=self._value_var, |
| 245 | width=150, |
| 246 | height=32, |
| 247 | fg_color=COLORS["bg_light"], |
| 248 | border_color=COLORS["border"], |
| 249 | text_color=COLORS["text_primary"], |
| 250 | ) |
| 251 | self._input_widget.grid(row=0, column=1, sticky="w", pady=5) |
| 252 | |
| 253 | elif self._type_hint.startswith("choice:"): |
| 254 | choices = self._type_hint.replace("choice:", "").split(",") |
| 255 | self._value_var = ctk.StringVar(value=str(value)) |
| 256 | self._input_widget = ctk.CTkComboBox( |
| 257 | self, |
| 258 | values=choices, |
| 259 | variable=self._value_var, |
| 260 | command=lambda v: self._on_value_change(), |
| 261 | width=180, |
| 262 | height=32, |
| 263 | fg_color=COLORS["bg_light"], |
| 264 | border_color=COLORS["border"], |
| 265 | button_color=COLORS["accent"], |
| 266 | button_hover_color=COLORS["accent_hover"], |
no test coverage detected