MCPcopy Create free account
hub / github.com/CJackHwang/AIstudioProxyAPI / CTkCollapsibleFrame

Class CTkCollapsibleFrame

gui/widgets.py:15–139  ·  view source on GitHub ↗

A collapsible frame widget that can be expanded/collapsed by clicking the header. The header shows a title with an expand/collapse indicator, and the content area can contain any widgets.

Source from the content-addressed store, hash-verified

13
14
15class CTkCollapsibleFrame(ctk.CTkFrame):
16 """
17 A collapsible frame widget that can be expanded/collapsed by clicking the header.
18
19 The header shows a title with an expand/collapse indicator, and the content
20 area can contain any widgets.
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:

Callers 1

_build_settings_uiMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected