From 5df5fd7d167f234efc0857629605c56613737d01 Mon Sep 17 00:00:00 2001 From: Shlomo Zalman Rabinowitz <106286969+SZRabinowitz@users.noreply.github.com> Date: Fri, 24 Jan 2025 03:04:22 -0500 Subject: [PATCH] add multiply to ttkspacer - Override the multiplication dunder for ttkspacer to support creating multiple spacers at a time. for example: ``` row_2.addWidgets([ttk.TTkButton(text="Submit"), *ttk.TTkSpacer() * 3]) ``` --- TermTk/TTkWidgets/spacer.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/TermTk/TTkWidgets/spacer.py b/TermTk/TTkWidgets/spacer.py index bb48dd06..82c2881a 100644 --- a/TermTk/TTkWidgets/spacer.py +++ b/TermTk/TTkWidgets/spacer.py @@ -29,3 +29,10 @@ class TTkSpacer(TTkWidget): __slots__ = () def __init__(self, **kwargs) -> None: TTkWidget.__init__(self, **kwargs) + + def __mul__(self, num:int): + if not isinstance(num, int): + raise ValueError(f"Expected int but got {type(num)}") + return [TTkSpacer() for _ in range(num)] + +