Deerie
Deerie

Reputation: 21

Using RGB values in TKinter? EG. 255, 0, 0

Heyo! So, I've been working on this project, but I need some help. I'd like to be able to use the RGB values in tinker, for example:

color = askcolor()
canvas.create_oval(x0, y0, x0 + d, y0 + d, fill = color)

but when I do that, I get the following error:

tkinter.TclError: unknown color name "{254.9921875 67.26171875 67.26171875} #fe4343"

Is there any way I could either change that value to the nearest TKinter color or use that value in TKinter?

Upvotes: 1

Views: 1760

Answers (1)

Clément
Clément

Reputation: 1256

askcolor return a tuple of two values. The first one is an RGB tuple of the chosen color. The second one is a hexadecimal string of the chosen color.

Try to use :

fill = color[1]

tkinter color dialogs documentation

By the way, the error message shows the two values returned.

Upvotes: 2

Related Questions