fix: _btn pop font/width/height so CTkButton never gets duplicate kwargs
Made-with: Cursor
This commit is contained in:
@@ -111,25 +111,26 @@ def main() -> None:
|
||||
# HELPERS
|
||||
# ─────────────────────────────────────────────────────────────────────────
|
||||
def _btn(parent: Any, label: str, cmd: Any, w: int = 80, h: int = 28, **kw: Any) -> ctk.CTkButton:
|
||||
# Merge styling; pass font / corner_radius explicitly so nothing duplicates
|
||||
# inside CTkButton (font must not appear in **kwargs passed to the base class).
|
||||
merged: dict[str, Any] = {
|
||||
"fg_color": ACCENT,
|
||||
"hover_color": ACCENT2,
|
||||
"text_color": TEXT,
|
||||
**kw,
|
||||
}
|
||||
font = merged.pop("font", (FONT, 11))
|
||||
corner_radius = merged.pop("corner_radius", 6)
|
||||
# Pop styling keys so they are never duplicated in **kw (CustomTkinter raises on duplicate font, etc.).
|
||||
font = kw.pop("font", (FONT, 11))
|
||||
fg_color = kw.pop("fg_color", ACCENT)
|
||||
hover_color = kw.pop("hover_color", ACCENT2)
|
||||
text_color = kw.pop("text_color", TEXT)
|
||||
corner_radius = kw.pop("corner_radius", 6)
|
||||
width = kw.pop("width", w)
|
||||
height = kw.pop("height", h)
|
||||
return ctk.CTkButton(
|
||||
parent,
|
||||
text=label,
|
||||
command=cmd,
|
||||
width=w,
|
||||
height=h,
|
||||
corner_radius=corner_radius,
|
||||
width=width,
|
||||
height=height,
|
||||
font=font,
|
||||
**merged,
|
||||
fg_color=fg_color,
|
||||
hover_color=hover_color,
|
||||
text_color=text_color,
|
||||
corner_radius=corner_radius,
|
||||
**kw,
|
||||
)
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user