1 year ago
#362508
Itayo
Tkinter Change the color of a certain line in a textbox
I'm trying to change the color of a line in a textbox to a hex code without affecting the rest of the lines. I've tried using insert tags but they change the previous lines as well. Is there a way to achieve my goal? | What I'm trying to achieve |
Heres my current code:
def receivemessages():
...
elif message[0:1] == "#":
color = message[0:7]
message = message[7:]
entry_2.config(state=tkinter.NORMAL)
entry_2.tag_config('usermessage', foreground=color)
entry_2.insert(tkinter.END, message + '\n', 'usermessage')
entry_2.see("end")
entry_2.config(state=tkinter.DISABLED)
| What I get |
tags are probably the wrong thing to use here but I'm failing to find other solutions online. if someone can point me in the right direction it would be much appreciated.
tkinter
tkinter-text
0 Answers
Your Answer