added update_idletasks call to base class set_appearance_mode

This commit is contained in:
Tom Schimansky 2022-11-30 22:03:42 +01:00
parent 50a8bb140e
commit 0d8a79d783
3 changed files with 13 additions and 12 deletions

View File

@ -220,6 +220,7 @@ class CTkBaseClass(tkinter.Frame, CTkAppearanceModeBaseClass, CTkScalingBaseClas
def _set_appearance_mode(self, mode_string):
super()._set_appearance_mode(mode_string)
self._draw()
super().update_idletasks()
def _set_scaling(self, new_widget_scaling, new_window_scaling):
super()._set_scaling(new_widget_scaling, new_window_scaling)

View File

@ -94,6 +94,8 @@ class CTkFrame(CTkBaseClass):
def _draw(self, no_color_updates=False):
super()._draw(no_color_updates)
print("frame draw", no_color_updates)
if not self._canvas.winfo_exists():
return

View File

@ -15,13 +15,13 @@ class App(customtkinter.CTk):
self.grid_columnconfigure(1, weight=1)
# load images with light and dark mode image
current_path = os.path.dirname(os.path.realpath(__file__))
self.home_image = customtkinter.CTkImage(light_image=Image.open(os.path.join(current_path, "test_images", "home_dark.png")),
dark_image=Image.open(os.path.join(current_path, "test_images", "home_light.png")), size=(20, 20))
self.chat_image = customtkinter.CTkImage(light_image=Image.open(os.path.join(current_path, "test_images", "chat_dark.png")),
dark_image=Image.open(os.path.join(current_path, "test_images", "chat_light.png")), size=(20, 20))
self.add_user_image = customtkinter.CTkImage(light_image=Image.open(os.path.join(current_path, "test_images", "add_user_dark.png")),
dark_image=Image.open(os.path.join(current_path, "test_images", "add_user_light.png")), size=(20, 20))
image_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "test_images")
self.home_image = customtkinter.CTkImage(light_image=Image.open(os.path.join(image_path, "home_dark.png")),
dark_image=Image.open(os.path.join(image_path, "home_light.png")), size=(20, 20))
self.chat_image = customtkinter.CTkImage(light_image=Image.open(os.path.join(image_path, "chat_dark.png")),
dark_image=Image.open(os.path.join(image_path, "chat_light.png")), size=(20, 20))
self.add_user_image = customtkinter.CTkImage(light_image=Image.open(os.path.join(image_path, "add_user_dark.png")),
dark_image=Image.open(os.path.join(image_path, "add_user_light.png")), size=(20, 20))
# create navigation frame
self.navigation_frame = customtkinter.CTkFrame(self, corner_radius=0)
@ -51,15 +51,15 @@ class App(customtkinter.CTk):
# create home frame
self.home_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color="transparent")
self.home_frame.grid(row=0, column=1, sticky="nsew")
# create chat frame
self.chat_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color="transparent")
self.chat_frame.grid(row=0, column=1, sticky="nsew")
# create add user frame
self.add_user_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color="transparent")
self.add_user_frame.grid(row=0, column=1, sticky="nsew")
# select default frame
self.select_frame_by_name("home")
def select_frame_by_name(self, name):
# set button color for selected button
@ -80,8 +80,6 @@ class App(customtkinter.CTk):
self.home_frame.grid(row=0, column=1, sticky="nsew")
else:
self.home_frame.grid_forget()
self.chat_button.configure(fg_color="transparent")
self.add_user_button.configure(fg_color="transparent")
def home_button_event(self):
self.select_frame_by_name("home")