0

I made a python script to find some lyrics by specific words, and when i show the result I want to recolor that searched word.

I have a click listener on a button, which calls the corresponding function, named bestMatch. The result is big string, which will be the text of my result label.

import tkinter as tk

def clickMe():
    global window
    global results
    global name
    retValue = bestMatch(name.get())
    result = ''
    for i in retValue:
        result = result + enekeskonyv[int(i[0])] + '\n'
    for widget in resultFrame.winfo_children():
        widget.destroy()
    tk.Label(resultFrame, text= 'Result by- ' + name.get() + ': \n' + result).grid(padx=10, sticky=W)

That last label will contain my result, and I did not found any recolor methods for tkinter labels.

  • 1
    Does this answer your question? [How to change the color of certain words in the tkinter text widget?](https://stackoverflow.com/questions/14786507/how-to-change-the-color-of-certain-words-in-the-tkinter-text-widget) – MHP Aug 14 '21 at 11:41
  • can't do that in a Label, use Text widget, see the link above – Matiiss Aug 14 '21 at 11:48

1 Answers1

0

You can't change some of the text in a label widget, but you can do that with text widget:

How to change the color of certain words in the tkinter text widget?

Eladtopaz
  • 1,036
  • 1
  • 6
  • 21