removed print from CTkSegmentedButton

This commit is contained in:
TomSchimansky 2022-10-08 13:50:11 +02:00
parent 327957e97a
commit dbf5577cf0
3 changed files with 9 additions and 7 deletions

View File

@ -59,7 +59,7 @@ class CTkSegmentedButton(CTkFrame):
self._dynamic_resizing = dynamic_resizing self._dynamic_resizing = dynamic_resizing
if not self._dynamic_resizing: if not self._dynamic_resizing:
self.grid_propagate(0) self.grid_propagate(False)
self._check_unique_values(self._value_list) self._check_unique_values(self._value_list)
self._current_value: str = "" self._current_value: str = ""
@ -241,9 +241,9 @@ class CTkSegmentedButton(CTkFrame):
if "dynamic_resizing" in kwargs: if "dynamic_resizing" in kwargs:
self._dynamic_resizing = kwargs.pop("dynamic_resizing") self._dynamic_resizing = kwargs.pop("dynamic_resizing")
if not self._dynamic_resizing: if not self._dynamic_resizing:
self.grid_propagate(0) self.grid_propagate(False)
else: else:
self.grid_propagate(1) self.grid_propagate(True)
super().configure(**kwargs) super().configure(**kwargs)
@ -252,6 +252,7 @@ class CTkSegmentedButton(CTkFrame):
return self._sb_corner_radius return self._sb_corner_radius
elif attribute_name == "border_width": elif attribute_name == "border_width":
return self._sb_border_width return self._sb_border_width
elif attribute_name == "fg_color": elif attribute_name == "fg_color":
return self._sb_fg_color return self._sb_fg_color
elif attribute_name == "selected_color": elif attribute_name == "selected_color":
@ -266,18 +267,20 @@ class CTkSegmentedButton(CTkFrame):
return self._sb_text_color return self._sb_text_color
elif attribute_name == "text_color_disabled": elif attribute_name == "text_color_disabled":
return self._sb_text_color_disabled return self._sb_text_color_disabled
elif attribute_name == "values": elif attribute_name == "values":
return self._value_list return self._value_list
elif attribute_name == "variable": elif attribute_name == "variable":
return self._variable return self._variable
elif attribute_name == "dynamic_resizing": elif attribute_name == "dynamic_resizing":
return self._dynamic_resizing return self._dynamic_resizing
else: else:
return super().cget(attribute_name) return super().cget(attribute_name)
def set(self, value: str, from_variable_callback: bool = False): def set(self, value: str, from_variable_callback: bool = False):
if value == self._current_value: if value == self._current_value:
print("value == self._current_value") return
elif value in self._buttons_dict: elif value in self._buttons_dict:
self._select_button_by_value(value) self._select_button_by_value(value)

View File

@ -100,7 +100,7 @@ class App(customtkinter.CTk):
self.slider_progressbar_frame.grid_columnconfigure(0, weight=1) self.slider_progressbar_frame.grid_columnconfigure(0, weight=1)
self.slider_progressbar_frame.grid_rowconfigure(4, 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"]) values=["CTkSegmentedButton", "Value 2", "Value 3"])
self.seg_button.grid(row=0, column=0, padx=(20, 10), pady=(10, 10), sticky="ew") self.seg_button.grid(row=0, column=0, padx=(20, 10), pady=(10, 10), sticky="ew")

View File

@ -58,7 +58,7 @@ seg_6 = customtkinter._CTkSegmentedButton(app, width=300)
seg_6.pack(padx=20, pady=20) seg_6.pack(padx=20, pady=20)
entry_6 = customtkinter.CTkEntry(app) entry_6 = customtkinter.CTkEntry(app)
entry_6.pack(padx=20, pady=(0, 20)) 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.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 = customtkinter.CTkButton(app, text="insert value", command=lambda: seg_6.insert_value(0, entry_6.get()))
button_6.pack(padx=20, pady=(0, 20)) 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.configure(height=50, variable=seg_6_var)
seg_6.remove_value("CTkSegmentedButton") seg_6.remove_value("CTkSegmentedButton")
seg_6.configure(values=[])
app.mainloop() app.mainloop()