Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update button_hover_color #48

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions CTkMessagebox/ctkmessagebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,20 @@ def __init__(self,
else:
self.bt_text_color = button_text_color

default_button_hover_color = self._apply_appearance_mode(customtkinter.ThemeManager.theme["CTkButton"]["hover_color"])

if button_hover_color=="default":
self.bt_hv_color = self._apply_appearance_mode(customtkinter.ThemeManager.theme["CTkButton"]["hover_color"])
self.button_hover_color = (default_button_hover_color,default_button_hover_color,default_button_hover_color)
else:
self.bt_hv_color = button_hover_color
if type(button_hover_color) is tuple:
if len(button_hover_color)==2:
self.button_hover_color = (button_hover_color[0], button_hover_color[1], default_button_hover_color)
elif len(button_hover_color)==1:
self.button_hover_color = (button_hover_color[0], default_button_hover_color, default_button_hover_color)
else:
self.button_hover_color = button_hover_color
else:
self.button_hover_color = (button_hover_color, button_hover_color, button_hover_color)

if border_color=="default":
self.border_color = self._apply_appearance_mode(customtkinter.ThemeManager.theme["CTkFrame"]["border_color"])
Expand Down Expand Up @@ -241,22 +251,22 @@ def __init__(self,

self.button_1 = customtkinter.CTkButton(self.frame_top, text=self.option_text_1, fg_color=self.button_color[0],
width=self.button_width, font=self.font, text_color=self.bt_text_color,
hover_color=self.bt_hv_color, height=self.button_height,
hover_color=self.button_hover_color[0], height=self.button_height,
command=lambda: self.button_event(self.option_text_1))


self.option_text_2 = option_2
if option_2:
self.button_2 = customtkinter.CTkButton(self.frame_top, text=self.option_text_2, fg_color=self.button_color[1],
width=self.button_width, font=self.font, text_color=self.bt_text_color,
hover_color=self.bt_hv_color, height=self.button_height,
hover_color=self.button_hover_color[1], height=self.button_height,
command=lambda: self.button_event(self.option_text_2))

self.option_text_3 = option_3
if option_3:
self.button_3 = customtkinter.CTkButton(self.frame_top, text=self.option_text_3, fg_color=self.button_color[2],
width=self.button_width, font=self.font, text_color=self.bt_text_color,
hover_color=self.bt_hv_color, height=self.button_height,
hover_color=self.button_hover_color[2], height=self.button_height,
command=lambda: self.button_event(self.option_text_3))

if self.justify=="center":
Expand Down Expand Up @@ -342,7 +352,7 @@ def focus_button(self, option_focus):
try:
self.selected_button = getattr(self, "button_"+str(option_focus))
self.selected_button.focus()
self.selected_button.configure(border_color=self.bt_hv_color, border_width=3)
self.selected_button.configure(border_color=self.button_hover_color, border_width=3)
self.selected_option = getattr(self, "option_text_"+str(option_focus))
self.selected_button.bind("<Return>", lambda event: self.button_event(self.selected_option))
except AttributeError:
Expand Down