Skip to content

Color substring of text among Textbox #1600

@MoritzNekolla

Description

@MoritzNekolla

Hello,

is there a possibility to color just a substring of the text inside a customtinker.Textbox? Or highlight it otherwise?

In plain tkinter this is possible like so:

import tkinter as tk

# Create a new tkinter window
root = tk.Tk()

# Create a Text widget
text_widget = tk.Text(root, height=10, width=50)
text_widget.pack()

# Add text to the Text widget
text_widget.insert('end', 'This is some colored text.\n')

# Add a tag to color a substring
text_widget.tag_add('color', '1.5', '1.11') # '1.5' means first line, 5th character; '1.11' means first line, 11th character

# Configure the tag to set the text color
text_widget.tag_configure('color', foreground='red')

# Run the tkinter event loop
root.mainloop()

However customtinker only provides the text_color parameter, which colors the whole Text.

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    informationQuestions about details of CustomTkinter

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions