Initialize the collapsible frame. Args: master: Parent widget title: Title text for the header expanded: Initial expanded state on_toggle: Callback when expanded state changes **kwargs: Additional CTkFrame arguments
(
self,
master: Any,
title: str,
expanded: bool = False,
on_toggle: Optional[Callable[[bool], None]] = None,
**kwargs,
)
| 21 | """ |
| 22 | |
| 23 | def __init__( |
| 24 | self, |
| 25 | master: Any, |
| 26 | title: str, |
| 27 | expanded: bool = False, |
| 28 | on_toggle: Optional[Callable[[bool], None]] = None, |
| 29 | **kwargs, |
| 30 | ): |
| 31 | """ |
| 32 | Initialize the collapsible frame. |
| 33 | |
| 34 | Args: |
| 35 | master: Parent widget |
| 36 | title: Title text for the header |
| 37 | expanded: Initial expanded state |
| 38 | on_toggle: Callback when expanded state changes |
| 39 | **kwargs: Additional CTkFrame arguments |
| 40 | """ |
| 41 | # Set default frame styling |
| 42 | kwargs.setdefault("fg_color", COLORS["bg_medium"]) |
| 43 | kwargs.setdefault("corner_radius", DIMENSIONS["corner_radius"]) |
| 44 | |
| 45 | super().__init__(master, **kwargs) |
| 46 | |
| 47 | self._title = title |
| 48 | self._expanded = expanded |
| 49 | self._on_toggle = on_toggle |
| 50 | self._content_widgets: List[Any] = [] |
| 51 | |
| 52 | # Configure grid |
| 53 | self.grid_columnconfigure(0, weight=1) |
| 54 | |
| 55 | # Create header |
| 56 | self._create_header() |
| 57 | |
| 58 | # Create content container |
| 59 | self._content_frame = ctk.CTkFrame( |
| 60 | self, |
| 61 | fg_color="transparent", |
| 62 | ) |
| 63 | |
| 64 | # Initial state |
| 65 | if self._expanded: |
| 66 | self._content_frame.grid( |
| 67 | row=1, column=0, sticky="ew", padx=10, pady=(0, 10) |
| 68 | ) |
| 69 | |
| 70 | self._update_header_text() |
| 71 | |
| 72 | def _create_header(self) -> None: |
| 73 | """Create the clickable header.""" |
nothing calls this directly
no test coverage detected