From dbf5577cf036f8b7923940665f68aaf7fc86becb Mon Sep 17 00:00:00 2001 From: TomSchimansky Date: Sat, 8 Oct 2022 13:50:11 +0200 Subject: [PATCH] removed print from CTkSegmentedButton --- customtkinter/widgets/ctk_segmented_button.py | 11 +++++++---- test/manual_integration_tests/complex_example_new.py | 2 +- .../manual_integration_tests/test_segmented_button.py | 3 +-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/customtkinter/widgets/ctk_segmented_button.py b/customtkinter/widgets/ctk_segmented_button.py index 7e0ead1..36657f2 100644 --- a/customtkinter/widgets/ctk_segmented_button.py +++ b/customtkinter/widgets/ctk_segmented_button.py @@ -59,7 +59,7 @@ class CTkSegmentedButton(CTkFrame): self._dynamic_resizing = dynamic_resizing if not self._dynamic_resizing: - self.grid_propagate(0) + self.grid_propagate(False) self._check_unique_values(self._value_list) self._current_value: str = "" @@ -241,9 +241,9 @@ class CTkSegmentedButton(CTkFrame): if "dynamic_resizing" in kwargs: self._dynamic_resizing = kwargs.pop("dynamic_resizing") if not self._dynamic_resizing: - self.grid_propagate(0) + self.grid_propagate(False) else: - self.grid_propagate(1) + self.grid_propagate(True) super().configure(**kwargs) @@ -252,6 +252,7 @@ class CTkSegmentedButton(CTkFrame): return self._sb_corner_radius elif attribute_name == "border_width": return self._sb_border_width + elif attribute_name == "fg_color": return self._sb_fg_color elif attribute_name == "selected_color": @@ -266,18 +267,20 @@ class CTkSegmentedButton(CTkFrame): return self._sb_text_color elif attribute_name == "text_color_disabled": return self._sb_text_color_disabled + elif attribute_name == "values": return self._value_list elif attribute_name == "variable": return self._variable elif attribute_name == "dynamic_resizing": return self._dynamic_resizing + else: return super().cget(attribute_name) def set(self, value: str, from_variable_callback: bool = False): if value == self._current_value: - print("value == self._current_value") + return elif value in self._buttons_dict: self._select_button_by_value(value) diff --git a/test/manual_integration_tests/complex_example_new.py b/test/manual_integration_tests/complex_example_new.py index ad4511b..d9b49f8 100644 --- a/test/manual_integration_tests/complex_example_new.py +++ b/test/manual_integration_tests/complex_example_new.py @@ -100,7 +100,7 @@ class App(customtkinter.CTk): self.slider_progressbar_frame.grid_columnconfigure(0, weight=1) self.slider_progressbar_frame.grid_rowconfigure(4, weight=1) - self.seg_button = customtkinter._CTkSegmentedButton(self.slider_progressbar_frame, corner_radius=1000, + self.seg_button = customtkinter._CTkSegmentedButton(self.slider_progressbar_frame, values=["CTkSegmentedButton", "Value 2", "Value 3"]) self.seg_button.grid(row=0, column=0, padx=(20, 10), pady=(10, 10), sticky="ew") diff --git a/test/manual_integration_tests/test_segmented_button.py b/test/manual_integration_tests/test_segmented_button.py index f954649..d97e676 100644 --- a/test/manual_integration_tests/test_segmented_button.py +++ b/test/manual_integration_tests/test_segmented_button.py @@ -58,7 +58,7 @@ seg_6 = customtkinter._CTkSegmentedButton(app, width=300) seg_6.pack(padx=20, pady=20) entry_6 = customtkinter.CTkEntry(app) entry_6.pack(padx=20, pady=(0, 20)) -button_6 = customtkinter.CTkButton(app, text="set", command=lambda: seg_6.set(entry_6.get())) +button_6 = customtkinter.CTkButton(app, text="set", command=lambda: seg_6.set(entry_6.get()), corner_radius=1000) button_6.pack(padx=20, pady=(0, 20)) button_6 = customtkinter.CTkButton(app, text="insert value", command=lambda: seg_6.insert_value(0, entry_6.get())) button_6.pack(padx=20, pady=(0, 20)) @@ -67,6 +67,5 @@ label_6.pack(padx=20, pady=(0, 20)) seg_6.configure(height=50, variable=seg_6_var) seg_6.remove_value("CTkSegmentedButton") -seg_6.configure(values=[]) app.mainloop()