added text_font configuration for all CTk widgets #266

This commit is contained in:
Tom Schimansky
2022-08-16 14:05:15 +02:00
parent f39ee5764a
commit 8c9183006c
10 changed files with 43 additions and 72 deletions

View File

@ -243,6 +243,11 @@ class CTkButton(CTkBaseClass):
else:
self.text_label.configure(text=self.text)
if "text_font" in kwargs:
self.text_font = kwargs.pop("text_font")
if self.text_label is not None:
self.text_label.configure(font=self.apply_font_scaling(self.text_font))
if "state" in kwargs:
self.state = kwargs.pop("state")
self.set_cursor()

View File

@ -177,6 +177,11 @@ class CTkCheckBox(CTkBaseClass):
self.text = kwargs.pop("text")
self.text_label.configure(text=self.text)
if "text_font" in kwargs:
self.text_font = kwargs.pop("text_font")
if self.text_label is not None:
self.text_label.configure(font=self.apply_font_scaling(self.text_font))
if "state" in kwargs:
self.state = kwargs.pop("state")
self.set_cursor()

View File

@ -203,6 +203,10 @@ class CTkComboBox(CTkBaseClass):
self.text_color = kwargs.pop("text_color")
require_redraw = True
if "text_font" in kwargs:
self.text_font = kwargs.pop("text_font")
self.entry.configure(font=self.apply_font_scaling(self.text_font))
if "command" in kwargs:
self.command = kwargs.pop("command")

View File

@ -185,6 +185,10 @@ class CTkEntry(CTkBaseClass):
self.textvariable = kwargs.pop("textvariable")
self.entry.configure(textvariable=self.textvariable)
if "text_font" in kwargs:
self.text_font = kwargs.pop("text_font")
self.entry.configure(font=self.apply_font_scaling(self.text_font))
if "show" in kwargs:
if self.placeholder_text_active:
self.pre_placeholder_arguments["show"] = kwargs.pop("show")

View File

@ -123,6 +123,10 @@ class CTkLabel(CTkBaseClass):
self.text_label.configure(text=self.text)
del kwargs["text"]
if "text_font" in kwargs:
self.text_font = kwargs.pop("text_font")
self.text_label.configure(font=self.apply_font_scaling(self.text_font))
if "fg_color" in kwargs:
self.fg_color = kwargs["fg_color"]
require_redraw = True

View File

@ -210,6 +210,10 @@ class CTkOptionMenu(CTkBaseClass):
self.text_color = kwargs.pop("text_color")
require_redraw = True
if "text_font" in kwargs:
self.text_font = kwargs.pop("text_font")
self.text_label.configure(font=self.apply_font_scaling(self.text_font))
if "command" in kwargs:
self.command = kwargs.pop("command")
@ -245,7 +249,8 @@ class CTkOptionMenu(CTkBaseClass):
self.dropdown_menu.configure(text_color=kwargs.pop("dropdown_text_color"))
if "dropdown_text_font" in kwargs:
self.dropdown_menu.configure(text_font=kwargs.pop("dropdown_text_font"))
self.dropdown_text_font = kwargs.pop("dropdown_text_font")
self.dropdown_menu.configure(text_font=self.dropdown_text_font)
if "dynamic_resizing" in kwargs:
self.dynamic_resizing = kwargs.pop("dynamic_resizing")

View File

@ -156,6 +156,10 @@ class CTkRadioButton(CTkBaseClass):
self.text = kwargs.pop("text")
self.text_label.configure(text=self.text)
if "text_font" in kwargs:
self.text_font = kwargs.pop("text_font")
self.text_label.configure(font=self.apply_font_scaling(self.text_font))
if "state" in kwargs:
self.state = kwargs.pop("state")
self.set_cursor()

View File

@ -272,6 +272,10 @@ class CTkSwitch(CTkBaseClass):
self.text = kwargs.pop("text")
self.text_label.configure(text=self.text)
if "text_font" in kwargs:
self.text_font = kwargs.pop("text_font")
self.text_label.configure(font=self.apply_font_scaling(self.text_font))
if "state" in kwargs:
self.state = kwargs.pop("state")
self.set_cursor()

View File

@ -161,6 +161,13 @@ class CTkTextbox(CTkBaseClass):
if "height" in kwargs:
self.set_dimensions(height=kwargs.pop("height"))
if "text_font" in kwargs:
self.text_font = kwargs.pop("text_font")
self.textbox.configure(font=self.apply_font_scaling(self.text_font))
if "font" in kwargs:
raise ValueError("No attribute named font. Use text_font instead of font for CTk widgets")
if "bg_color" in kwargs:
super().configure(bg_color=kwargs.pop("bg_color"), require_redraw=require_redraw)
else: