import tkinter as tk # importing the library used for graphical interface
import serial #for serial communication 

arduino = serial.Serial('com3','9600')      # com number and baud rate
def red():                      #defining a function
    arduino.write(b'1')         #sending a signal to arduino
def white():
    arduino.write(b'2')
def green():
    arduino.write(b'3')

win = tk.Tk()
win.title("Colours")            #window's title
win.configure(background="lightseagreen")       #to change the background colour

button=tk.Button()              #defining a variable (Button() is a reserved function)
top = tk.Frame()                #defining a variable as a frame
middle = tk.Frame()
bottom = tk.Frame()
top.pack()                      #pack is important to confirm a variable
middle.pack()
bottom.pack()
title= tk.Label(top ,text="Lights", font=('Bodoni MT Black',30),background="lightseagreen")        #title here is a variable to add a text
title.pack()
Name= tk.Label(middle, text="Pick your colour", font=('Arial BLack',23),background="lightseagreen")
Name.pack(side= tk.LEFT )

#port=tk.#Text(win)
#port.#pack()
Red= tk.Button(bottom, text="red ", font=('Arial Black',18),background="azure", command=red)           #creating a button, command calls a function
White=tk.Button (bottom, text="White", font=('Arial Black',18),background="azure", command=white)
Green=tk.Button (bottom, text="Green", font=('Arial Black',18),background="azure", command=green)       #the commands call for the functions i defined earlier
Red.pack(side= tk.LEFT)                 #when i put "left" i stack the buttons next to each other rather than make them under each others
White.pack(side= tk.LEFT)
Green.pack(side= tk.LEFT)

win.mainloop()      #so the window would stay openned

