From 103358d0379bf6bef8ab66aa41bf88695bcc8996 Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Fri, 14 Oct 2022 19:49:18 +0200 Subject: [PATCH] added move() method to CTkSegmentedButton --- customtkinter/widgets/ctk_segmented_button.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/customtkinter/widgets/ctk_segmented_button.py b/customtkinter/widgets/ctk_segmented_button.py index 8398a15..aa33a4d 100644 --- a/customtkinter/widgets/ctk_segmented_button.py +++ b/customtkinter/widgets/ctk_segmented_button.py @@ -371,6 +371,16 @@ class CTkSegmentedButton(CTkFrame): else: raise ValueError(f"CTkSegmentedButton can not insert value '{value}', already part of the values") + def move(self, new_index: int, value: str): + if 0 <= new_index < len(self._value_list): + if value in self._buttons_dict: + self.delete(value) + self.insert(new_index, value) + else: + raise ValueError(f"CTkSegmentedButton has no value named {value}") + else: + raise ValueError(f"CTkSegmentedButton new_index {new_index} not in range of value list with len {len(self._value_list)}") + def delete(self, value: str): if value in self._buttons_dict: self._buttons_dict[value].destroy()