Textbox widget with automatic x and y scrollbars, rounded corners, and all text features of the tkinter.Text widget. Scrollbars only appear when needed. Text wraps at line end by default.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/TomSchimansky/CustomTkinter/llms.txt
Use this file to discover all available pages before exploring further.
Constructor
Parent widget
Width of the textbox in pixels
Height of the textbox in pixels
Corner radius in pixels
Border width in pixels
Spacing between border and inner text widget
Background color
Foreground color of the textbox area
Border color
Color of the text
Color of the scrollbar button
Hover color of the scrollbar button
Font of the text
Enable automatic scrollbars when content overflows
Additional tkinter.Text arguments:
autoseparators, cursor, exportselection, insertborderwidth, insertofftime, insertontime, insertwidth, maxundo, padx, pady, selectborderwidth, spacing1, spacing2, spacing3, state, tabs, takefocus, undo, wrap, xscrollcommand, yscrollcommandMethods
CTkTextbox inherits all methods from tkinter.Text. Below are the most commonly used methods:insert
Position to insert text (e.g., “1.0” for beginning, “end” for end)
Text to insert
Optional tags to apply to the inserted text
get
Starting position (e.g., “1.0”)
Ending position (defaults to one character after index1)
delete
configure
Tag Methods
The following tag methods are inherited from tkinter.Text:.tag_add(tagName, index1, index2)- Add a tag to text range.tag_config(tagName, **kwargs)- Configure tag appearance (note: font option is forbidden).tag_delete(*tagName)- Delete tags.tag_remove(tagName, index1, index2)- Remove tag from text range.tag_bind(tagName, sequence, func, add=None)- Bind event to tagged text.tag_names(index=None)- Get tag names
Search and Navigation
.search(pattern, index, **kwargs)- Search for text pattern.see(index)- Scroll to make index visible.index(i)- Get canonical index
Edit Methods
.edit_undo()- Undo last change.edit_redo()- Redo last undone change.edit_modified(arg=None)- Get/set modified flag.edit_separator()- Insert undo separator
View Methods
.xview(*args)- Query/modify horizontal view.yview(*args)- Query/modify vertical view
Scrollbars
CTkTextbox automatically manages two CTkScrollbar widgets:- Vertical scrollbar: Appears when content height exceeds widget height
- Horizontal scrollbar: Appears when content width exceeds widget width (requires
wrap="none")
Usage Examples
Basic Text Input
Get Text Content
Disable Text Wrapping
Using Text Tags for Styling
Read-Only Textbox
Custom Scrollbar Colors
Undo/Redo Support
Text Widget Indices
When working with text methods, indices use the format"line.column":
"1.0"- Beginning of the first line"end"- End of all text"insert"- Current cursor position"2.5"- Line 2, column 5