I would write the RGB code. That way you can send any color and the sender and receiver don't need to maintain color dictionaries. I wrote a Python program that prompts for RGB values and writes a string to a file. I wrote a second Python program there periodically reads the RGB values from the file and sets the background of a tkinter window to that color. I used a file because I don't have a serial port.
The program that displays the color:
from tkinter import *
root = Tk()
def check_for_command():
try:
with open('color.txt', 'r') as file:
for line in file:
r, g, b = map(int, line.split(','))
root['bg'] = f'#{r:02x}{g:02x}{b:02x}'
except:
pass
root.after(1000, check_for_command)
check_for_command()
root.mainloop()
The program that writes the color information:
r = int(input('Red '))
g = int(input('Green '))
b = int(input('Blue '))
with open('color.txt', 'w') as file:
file.write(f'{r},{g},{b}')
After I start the display program I can run the write program multiple times and see the changes in the display window.
I could rewrite this program to pass color names. This is the display side that supports tkinter color names:
from tkinter import *
root = Tk()
def check_for_command():
try:
with open('color.txt', 'r') as file:
for line in file:
root['bg'] = line
except:
pass
root.after(1000, check_for_command)
check_for_command()
root.mainloop()
This is the program that writes the color file:
with open('color.txt', 'w') as file:
file.write(input('Enter color name ')