-
Notifications
You must be signed in to change notification settings - Fork 1.1k
CTkLabel
Tom Schimansky edited this page Feb 5, 2023
·
9 revisions
Default theme:
label = customtkinter.CTkLabel(master=root_tk, text="CTkLabel")
label.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
Customized:
text_var = tkinter.StringVar(value="CTkLabel")
label = customtkinter.CTkLabel(master=root_tk,
textvariable=text_var,
width=120,
height=25,
fg_color=("white", "gray75"),
corner_radius=8)
label.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
argument | value |
---|---|
master | root, tkinter.Frame or CTkFrame |
textvariable | tkinter.StringVar object |
text | string |
width | label width in px |
height | label height in px |
corner_radius | corner radius in px |
fg_color | foreground color, tuple: (light_color, dark_color) or single color or "transparent" |
text_color | label text color, tuple: (light_color, dark_color) or single color |
font | label text font, tuple: (font_name, size) |
anchor | controls where the text is positioned if the widget has more space than the text needs, default is "center" |
compound | control the postion of image relative to text, default is "center, other are: "top", "bottom", "left", "right" |
justify | specifies how multiple lines of text will be aligned with respect to each other: "left" for flush left, "center" for centered (the default), or "right" for right-justified |
padx | extra space added left and right of the text, default is 1 |
pady | extra space added above and belowof the text, default is 1 |
and other arguments of tkinter.Label
-
All attributes can be configured and updated.
ctk_label.configure(text=new_text) ...
-
Pass attribute name as string and get current value of attribute.
text = ctk_label.cget("text") ...
-
Bind events to the label.
CustomTkinter by Tom Schimansky 2022
The Github Wiki is outdated, the new documentation can be found at: