From 7572f095c21d136d24067ad58c2547921e93af3b Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Tue, 6 Dec 2022 18:47:39 +0100 Subject: [PATCH] cget now returns copy of lists --- customtkinter/windows/widgets/ctk_combobox.py | 3 ++- customtkinter/windows/widgets/ctk_optionmenu.py | 3 ++- customtkinter/windows/widgets/ctk_segmented_button.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/customtkinter/windows/widgets/ctk_combobox.py b/customtkinter/windows/widgets/ctk_combobox.py index 80c84dd..5218d68 100644 --- a/customtkinter/windows/widgets/ctk_combobox.py +++ b/customtkinter/windows/widgets/ctk_combobox.py @@ -1,5 +1,6 @@ import tkinter import sys +import copy from typing import Union, Tuple, Callable, List, Optional from .core_widget_classes import DropdownMenu @@ -324,7 +325,7 @@ class CTkComboBox(CTkBaseClass): elif attribute_name == "dropdown_font": return self._dropdown_menu.cget("font") elif attribute_name == "values": - return self._values + return copy.copy(self._values) elif attribute_name == "state": return self._state elif attribute_name == "hover": diff --git a/customtkinter/windows/widgets/ctk_optionmenu.py b/customtkinter/windows/widgets/ctk_optionmenu.py index 64f661c..3e6400c 100644 --- a/customtkinter/windows/widgets/ctk_optionmenu.py +++ b/customtkinter/windows/widgets/ctk_optionmenu.py @@ -1,4 +1,5 @@ import tkinter +import copy import sys from typing import Union, Tuple, Callable, Optional @@ -328,7 +329,7 @@ class CTkOptionMenu(CTkBaseClass): elif attribute_name == "dropdown_font": return self._dropdown_menu.cget("font") elif attribute_name == "values": - return self._values + return copy.copy(self._values) elif attribute_name == "variable": return self._variable elif attribute_name == "state": diff --git a/customtkinter/windows/widgets/ctk_segmented_button.py b/customtkinter/windows/widgets/ctk_segmented_button.py index 73e9df2..5ea46ca 100644 --- a/customtkinter/windows/widgets/ctk_segmented_button.py +++ b/customtkinter/windows/widgets/ctk_segmented_button.py @@ -1,4 +1,5 @@ import tkinter +import copy from typing import Union, Tuple, List, Dict, Callable, Optional try: from typing import Literal @@ -321,7 +322,7 @@ class CTkSegmentedButton(CTkFrame): elif attribute_name == "font": return self._font elif attribute_name == "values": - return self._value_list + return copy.copy(self._value_list) elif attribute_name == "variable": return self._variable elif attribute_name == "dynamic_resizing":