added text_font argument to CTkEntry

This commit is contained in:
Tom Schimansky 2022-01-29 23:55:48 +01:00
parent 8625fbb0f6
commit f5cac7b978
2 changed files with 13 additions and 1 deletions

View File

@ -123,7 +123,7 @@ The color themes look like the following in light and dark mode:
### CustomTkinter on Windows/Linux
All elements of Customtkinter are drawn on the ```tkinter.Canvas```.
But the Tkinter canvas supports antialiasing only on macOS, so on Windows
But the Tkinter canvas supports antialiasing only on macOS (provided by the system), so on Windows
and Linux the elements are rendered in a much worse quality. So you have
to experiment with the ```corner_radius``` and decide when the rounded corners
look best. I tried to design the too complex example programs so that they

View File

@ -13,6 +13,7 @@ class CTkEntry(tkinter.Frame):
bg_color=None,
fg_color="CTkColorManager",
text_color="CTkColorManager",
text_font=None,
corner_radius=8,
width=120,
height=30,
@ -52,6 +53,16 @@ class CTkEntry(tkinter.Frame):
self.fg_color = CTkColorManager.ENTRY if fg_color == "CTkColorManager" else fg_color
self.text_color = CTkColorManager.TEXT if text_color == "CTkColorManager" else text_color
if text_font is None:
if sys.platform == "darwin": # macOS
self.text_font = ("Avenir", 13)
elif "win" in sys.platform: # Windows
self.text_font = ("Century Gothic", 10)
else:
self.text_font = ("TkDefaultFont", 10)
else:
self.text_font = text_font
self.width = width
self.height = height
@ -74,6 +85,7 @@ class CTkEntry(tkinter.Frame):
bd=0,
width=1,
highlightthicknes=0,
font=self.text_font,
**kwargs)
self.entry.grid(column=0, row=0, sticky="we", padx=self.corner_radius if self.corner_radius >= 6 else 6)