diff --git a/customtkinter/widgets/ctk_segmented_button.py b/customtkinter/widgets/ctk_segmented_button.py index aa33a4d..b208bec 100644 --- a/customtkinter/widgets/ctk_segmented_button.py +++ b/customtkinter/widgets/ctk_segmented_button.py @@ -377,7 +377,7 @@ class CTkSegmentedButton(CTkFrame): self.delete(value) self.insert(new_index, value) else: - raise ValueError(f"CTkSegmentedButton has no value named {value}") + 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)}") diff --git a/customtkinter/widgets/ctk_tabview.py b/customtkinter/widgets/ctk_tabview.py index 23f83ff..24e2c1a 100644 --- a/customtkinter/widgets/ctk_tabview.py +++ b/customtkinter/widgets/ctk_tabview.py @@ -316,6 +316,15 @@ class CTkTabview(CTkBaseClass): """ appends new tab with given name """ return self.insert(len(self._tab_dict), name) + def move(self, new_index: int, name: str): + if 0 <= new_index < len(self._name_list): + if name in self._tab_dict: + self._segmented_button.move(new_index, name) + else: + raise ValueError(f"CTkTabview has no name '{name}'") + else: + raise ValueError(f"CTkTabview new_index {new_index} not in range of name list with len {len(self._name_list)}") + def delete(self, name: str): """ delete tab by name """ diff --git a/test/manual_integration_tests/test_tabview.py b/test/manual_integration_tests/test_tabview.py index e168342..cfd9e7b 100644 --- a/test/manual_integration_tests/test_tabview.py +++ b/test/manual_integration_tests/test_tabview.py @@ -5,8 +5,8 @@ app = customtkinter.CTk() tabview_1 = customtkinter._CTkTabview(app, state="disabled") tabview_1.pack(padx=20, pady=20) -tab_1 = tabview_1.add("tab 2") -tabview_1.insert(0, "tab 1") +tab_1 = tabview_1.add("tab 1") +tabview_1.insert(0, "tab 2") tabview_1.add("tab 42") tabview_1.set("tab 42") @@ -16,12 +16,15 @@ tabview_1.delete("tab 42") tabview_1.insert(1, "tab 42") tabview_1.delete("tab 42") -#b1 = customtkinter.CTkButton(master=tab_1, text="button tab 1") -#b1.pack(pady=20) +tabview_1.move(0, "tab 3") + +b1 = customtkinter.CTkButton(master=tab_1, text="button tab 1") +b1.pack(pady=20) b2 = customtkinter.CTkButton(master=tabview_1.tab("tab 2"), text="button tab 2") b2.pack() tabview_1.tab("tab 2").configure(fg_color="red") +tabview_1.configure(state="normal") # tabview_1.delete("tab 1") app.mainloop()