'How to assign RGB value to the Entry in Tkinter? (without classes)
sorry if I am being stupid, but. I am trying to create a custom cyan border with RGB values of (122,197,205) to a border of an Entry.
#Typing field
typingField = Entry(gui, bg='grey',highlightthickness=5, width=40, font=('Arial 27'))
typingField.config(highlightbackground = "red", highlightcolor= "red")
typingField.place(x=92, y=310)
right now I have set it to make a red one, but I need cyan one. I tryied to just write:
typingField.config(highlightbackground = (122,197,205), highlightcolor= (122,197,205))
but it doesn't work. I searched online but came to no results explaining how to do it without classes. I must not use them. Please enlighten me
Solution 1:[1]
You can use a string of hex values. Like you would in html or css.
name_entry.config(highlightbackground="#7ac5cd", highlightcolor="#7ac5cd")
A simple function (minus error checking) for converting the rgb values to a hex string would be.
def rgb2hex(r, g, b):
return f"#{r:02x}{g:02x}{b:02x}"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
