Skip to main content

CTkEntry

Example Code​

entry = customtkinter.CTkEntry(app, placeholder_text="CTkEntry")
CTkEntry example on macOS in dark mode
Changed in 6.0

The entry now loses the keyboard focus when you click somewhere else in the window.

Arguments​

argumentvalue
masterroot, tkinter.Frame or CTkFrame
textvariabletkinter.StringVar object
widthentry width in px
heightentry height in px
corner_radiuscorner radius in px
border_widthborder width 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
text_colorentry text color, tuple: (light_color, dark_color) or single color
placeholder_text_colortuple: (light_color, dark_color) or single color
placeholder_texthint on the entry input (disappears when selected), default is None, don't works in combination with a textvariable
fontentry text font, tuple: (font_name, size)
state"normal" (standard) or "disabled" (not clickable)

and the following arguments of the tkinter.Entry class:

"exportselection", "insertborderwidth", "insertofftime", "insertontime", "insertwidth", "justify", "selectborderwidth", "show", "takefocus", "validate", "validatecommand", "xscrollcommand"

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, for example:

    entry.configure(state="disabled")
  • .cget(attribute_name)​

    Pass attribute name as string and get current value of attribute, for example:

    state = entry.cget("state")
  • .bind(sequence=None, command=None, add=None)​

    Bind command function to event specified by sequence.

  • .delete(first_index, last_index=None)​

    Deletes characters from the widget, starting with the one at index first_index, up to but not including the character at position last_index. If the second argument is omitted, only the single character at position first is deleted.

  • .insert(index, string)​

    Inserts string before the character at the given index.

  • .get()​

    Returns current string in the entry.

  • .set(string)​

    Replace the whole content of the entry with the given string. (new in 6.0)

  • .focus()​

  • .focus_force()​

  • .index(index)​

  • .icursor(index)​

  • .select_adjust(index)​

  • .select_from(index)​

  • .select_clear()​

  • .select_present()​

  • .select_range(start_index, end_index)​

  • .select_to(index)​

  • .xview(index)​

  • .xview_moveto(f)​

  • .xview_scroll(number, what)​