fix: _btn pass font/corner_radius explicitly (no duplicate font in CTkButton/super kwargs)
Made-with: Cursor
This commit is contained in:
@@ -111,17 +111,25 @@ def main() -> None:
|
|||||||
# HELPERS
|
# HELPERS
|
||||||
# ─────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────
|
||||||
def _btn(parent: Any, label: str, cmd: Any, w: int = 80, h: int = 28, **kw: Any) -> ctk.CTkButton:
|
def _btn(parent: Any, label: str, cmd: Any, w: int = 80, h: int = 28, **kw: Any) -> ctk.CTkButton:
|
||||||
# Merge defaults so callers can override font / colors without duplicate keyword errors.
|
# Merge styling; pass font / corner_radius explicitly so nothing duplicates
|
||||||
defaults: dict[str, Any] = {
|
# inside CTkButton (font must not appear in **kwargs passed to the base class).
|
||||||
|
merged: dict[str, Any] = {
|
||||||
"fg_color": ACCENT,
|
"fg_color": ACCENT,
|
||||||
"hover_color": ACCENT2,
|
"hover_color": ACCENT2,
|
||||||
"text_color": TEXT,
|
"text_color": TEXT,
|
||||||
"font": (FONT, 11),
|
**kw,
|
||||||
}
|
}
|
||||||
defaults.update(kw)
|
font = merged.pop("font", (FONT, 11))
|
||||||
|
corner_radius = merged.pop("corner_radius", 6)
|
||||||
return ctk.CTkButton(
|
return ctk.CTkButton(
|
||||||
parent, text=label, command=cmd, width=w, height=h,
|
parent,
|
||||||
corner_radius=6, **defaults,
|
text=label,
|
||||||
|
command=cmd,
|
||||||
|
width=w,
|
||||||
|
height=h,
|
||||||
|
corner_radius=corner_radius,
|
||||||
|
font=font,
|
||||||
|
**merged,
|
||||||
)
|
)
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user