Skip to main content

CTkFrame

Example Code​

frame = customtkinter.CTkFrame(master=root_tk, width=200, height=200)
CTkFrame example on macOS in dark mode

Frame structured into a class:

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

# add widgets onto the frame, for example:
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()

Arguments​

argumentvalue
masterroot, Frame or Toplevel
widthwidth in px
heightheight in px
corner_radiuscorner radius in px
border_widthwidth of border in px
bg_colorcolor behind the widget, only visible at the rounded corners, "transparent" (default) takes the color of the parent widget, tuple: (light_color, dark_color) or single color
fg_colorforeground color, tuple: (light_color, dark_color) or single color or "transparent"
border_colorborder color, tuple: (light_color, dark_color) or single color
background_corner_colorstuple of four colors for the background behind the corners (top left, top right, bottom right, bottom left), useful if the frame sits between differently colored areas, default is None
overwrite_preferred_drawing_method"polygon_shapes", "font_shapes" or "circle_shapes", overrides the drawing method CustomTkinter chooses for the platform, default is None

Arguments and methods that all widgets share, like bg_color, .bind(), .focus() or .destroy(), are described on Common arguments and methods.

Methods​

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

    All attributes can be configured.

  • .cget(attribute_name)​

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

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

  • .winfo_children()​

    Returns a list of all child widgets placed on the frame, without the internal canvas the frame uses for drawing.