Skip to content

CTkFrame

Tom Schimansky edited this page Feb 6, 2023 · 9 revisions

Example Code:

frame = customtkinter.CTkFrame(master=root_tk, width=200, height=200)

Frame structured into a class:

import customtkinter


class MyFrame(customtkinter.CTkFrame):
    def __init__(self, master, **kwargs):
        super().__init__(master, **kwargs)

        # add widgets onto the frame...
        self.label = customtkinter.CTkLabel(self)
        self.label.grid(row=0, column=0, padx=20)


class App(customtkinter.CTk):
    def __init__(self):
        super().__init__()
        self.geometry("400x200")
        self.grid_rowconfigure(0, weight=1)  # configure grid system
        self.grid_columnconfigure(0, weight=1)

        self.my_frame = MyFrame(master=self)
        self.my_frame.grid(row=0, column=0, padx=20, pady=20, sticky="nsew")


app = App()
app.mainloop()

which results in:

Bildschirm­foto 2023-02-06 um 11 22 57

Arguments:

argument value
master root, Frame or Toplevel
width width in px
height height in px
border_width width of border in px
fg_color foreground color, tuple: (light_color, dark_color) or single color or "transparent"
border_color border color, tuple: (light_color, dark_color) or single color

Methods:

  • .configure(attribute=value, ...)

    All attributes can be configured and updated.

  • .cget(attribute_name)

    Pass attribute name as string and get current value of attribute.

  • .bind(sequence=None, command=None, add=None)

⚠️ Attention ⚠️

The Github Wiki is outdated, the new documentation can be found at:

https://customtkinter.tomschimansky.com

Clone this wiki locally