fixed bug in CTkLabel with multiline strings

This commit is contained in:
Tom Schimansky 2022-07-23 19:09:53 +02:00
parent 36702326fa
commit e295674e00
2 changed files with 6 additions and 3 deletions

View File

@ -119,7 +119,8 @@ class CTkLabel(CTkBaseClass):
sticky=text_label_grid_sticky)
if "text" in kwargs:
self.set_text(kwargs["text"])
self.text = kwargs["text"]
self.text_label.configure(text=self.text)
del kwargs["text"]
if "fg_color" in kwargs:
@ -148,5 +149,7 @@ class CTkLabel(CTkBaseClass):
self.text_label.configure(**kwargs) # pass remaining kwargs to label
def set_text(self, text):
""" Will be removed in the next major release """
self.text = text
self.text_label.configure(text=self.text, width=len(self.text))
self.text_label.configure(text=self.text)

View File

@ -37,7 +37,7 @@ class App(customtkinter.CTk):
self.appearance_mode_optionemenu = customtkinter.CTkOptionMenu(self.sidebar_frame, values=["Light", "Dark", "System"],
command=self.change_appearance_mode)
self.appearance_mode_optionemenu.grid(row=6, column=0, padx=20, pady=(10, 10))
self.scaling_label = customtkinter.CTkLabel(self.sidebar_frame, text="Widget Scaling:", anchor="w")
self.scaling_label = customtkinter.CTkLabel(self.sidebar_frame, text="UI Scaling:", anchor="w")
self.scaling_label.grid(row=7, column=0, padx=20, pady=(10, 0))
self.scaling_optionemenu = customtkinter.CTkOptionMenu(self.sidebar_frame, values=["80%", "90%", "100%", "110%", "120%"],
command=self.change_scaling)