diff --git a/customtkinter/windows/widgets/ctk_segmented_button.py b/customtkinter/windows/widgets/ctk_segmented_button.py index 8486c38c..4de9e4a5 100644 --- a/customtkinter/windows/widgets/ctk_segmented_button.py +++ b/customtkinter/windows/widgets/ctk_segmented_button.py @@ -125,15 +125,27 @@ def _configure_button_corners_for_index(self, index: int): elif index == 0: if self._background_corner_colors is None: - self._buttons_dict[self._value_list[index]].configure(background_corner_colors=(self._bg_color, self._sb_fg_color, self._sb_fg_color, self._bg_color)) + if self._vertical: + self._buttons_dict[self._value_list[index]].configure(background_corner_colors=(self._bg_color, self._bg_color, self._sb_fg_color, self._sb_fg_color)) + else: + self._buttons_dict[self._value_list[index]].configure(background_corner_colors=(self._bg_color, self._sb_fg_color, self._sb_fg_color, self._bg_color)) else: - self._buttons_dict[self._value_list[index]].configure(background_corner_colors=(self._background_corner_colors[0], self._sb_fg_color, self._sb_fg_color, self._background_corner_colors[3])) + if self._vertical: + self._buttons_dict[self._value_list[index]].configure(background_corner_colors=(self._background_corner_colors[0], self._background_corner_colors[1], self._sb_fg_color, self._sb_fg_color)) + else: + self._buttons_dict[self._value_list[index]].configure(background_corner_colors=(self._background_corner_colors[0], self._sb_fg_color, self._sb_fg_color, self._background_corner_colors[3])) elif index == len(self._value_list) - 1: if self._background_corner_colors is None: - self._buttons_dict[self._value_list[index]].configure(background_corner_colors=(self._sb_fg_color, self._bg_color, self._bg_color, self._sb_fg_color)) + if self._vertical: + self._buttons_dict[self._value_list[index]].configure(background_corner_colors=(self._sb_fg_color, self._sb_fg_color, self._bg_color, self._bg_color)) + else: + self._buttons_dict[self._value_list[index]].configure(background_corner_colors=(self._sb_fg_color, self._bg_color, self._bg_color, self._sb_fg_color)) else: - self._buttons_dict[self._value_list[index]].configure(background_corner_colors=(self._sb_fg_color, self._background_corner_colors[1], self._background_corner_colors[2], self._sb_fg_color)) + if self._vertical: + self._buttons_dict[self._value_list[index]].configure(background_corner_colors=(self._sb_fg_color, self._sb_fg_color, self._background_corner_colors[2], self._background_corner_colors[3])) + else: + self._buttons_dict[self._value_list[index]].configure(background_corner_colors=(self._sb_fg_color, self._background_corner_colors[1], self._background_corner_colors[2], self._sb_fg_color)) else: self._buttons_dict[self._value_list[index]].configure(background_corner_colors=(self._sb_fg_color, self._sb_fg_color, self._sb_fg_color, self._sb_fg_color)) @@ -181,7 +193,6 @@ def _check_unique_values(values: List[str]): def _create_button_grid(self): number_of_columns, number_of_rows = self.grid_size() - print(number_of_columns, number_of_rows) if self._vertical: # remove minsize from every grid cell in the first column for n in range(number_of_rows): diff --git a/test/manual_integration_tests/test_segmented_button.py b/test/manual_integration_tests/test_segmented_button.py index 79ef7ce4..41f0f1b0 100644 --- a/test/manual_integration_tests/test_segmented_button.py +++ b/test/manual_integration_tests/test_segmented_button.py @@ -55,27 +55,35 @@ label_seg_5 = customtkinter.CTkLabel(app, textvariable=seg_5_var) label_seg_5.pack(padx=20, pady=20) -seg_6_var = customtkinter.StringVar(value="kfasjkfdklaj") -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.pack(padx=20, pady=(0, 20)) -button_6 = customtkinter.CTkButton(app, text="insert value", command=lambda: seg_6.insert(0, entry_6.get())) -button_6.pack(padx=20, pady=(0, 20)) -label_6 = customtkinter.CTkLabel(app, textvariable=seg_6_var) -label_6.pack(padx=20, pady=(0, 20)) - -seg_6.configure(height=50, variable=seg_6_var) -seg_6.delete("CTkSegmentedButton") - -seg_7 = customtkinter.CTkSegmentedButton(app, values=["disabled seg button", "2", "3"]) -seg_7.pack(padx=20, pady=20) -seg_7.configure(state="disabled") -seg_7.set("2") - -seg_7.configure(height=40, width=400, +seg_6 = customtkinter.CTkSegmentedButton(app, corner_radius=20, values=["value 1", "value 2", "value 3"], background_corner_colors=["red", "orange", "green", "blue"], vertical=True) +seg_6.set("value 2") +seg_6.pack(side="left", padx=40) + +seg_7 = customtkinter.CTkSegmentedButton(app, corner_radius=40, values=["value 4", "value 5", "value 6"], vertical=True) +seg_7.set("value 6") +seg_7.pack(side="left") + +seg_8_var = customtkinter.StringVar(value="kfasjkfdklaj") +seg_8 = customtkinter.CTkSegmentedButton(app, width=300) +seg_8.pack(padx=20, pady=20) +entry_8 = customtkinter.CTkEntry(app) +entry_8.pack(padx=20, pady=(0, 20)) +button_8 = customtkinter.CTkButton(app, text="set", command=lambda: seg_8.set(entry_8.get())) +button_8.pack(padx=20, pady=(0, 20)) +button_8 = customtkinter.CTkButton(app, text="insert value", command=lambda: seg_8.insert(0, entry_8.get())) +button_8.pack(padx=20, pady=(0, 20)) +label_8 = customtkinter.CTkLabel(app, textvariable=seg_8_var) +label_8.pack(padx=20, pady=(0, 20)) + +seg_8.configure(height=50, variable=seg_8_var) +seg_8.delete("CTkSegmentedButton") + +seg_9 = customtkinter.CTkSegmentedButton(app, values=["disabled seg button", "2", "3"]) +seg_9.pack(padx=20, pady=20) +seg_9.configure(state="disabled") +seg_9.set("2") + +seg_9.configure(height=40, width=400, dynamic_resizing=False, font=("Times", -20)) app.mainloop()