import tkinter import serial data= serial.Serial('com3','9600') def zero(): data.write(b'1') def fortyFive(): data.write(b'2') def ninety(): data.write(b'3') def OneHundredAndThirtyFive(): data.write(b'4') def OneHundredAndNinety(): data.write(b'5') servo=tkinter.Tk() Button=tkinter.Button text=tkinter.Text zero=Button(servo, text="0 ", command=zero,height=8, width=16 ) fortyFive=Button(servo, text="45", command=fortyFive,height=8, width=16) ninety=Button(servo, text="90", command=ninety,height=8, width=16) OneHundredAndThirtyFive=Button(servo, text="135 ", command=OneHundredAndThirtyFive,height=8, width=16 ) OneHundredAndNinety=Button(servo, text="180 ", command=OneHundredAndNinety,height=8, width=16 ) zero.pack(side=tkinter.RIGHT) fortyFive.pack(side=tkinter.RIGHT) ninety.pack(side=tkinter.RIGHT) OneHundredAndThirtyFive.pack(side=tkinter.RIGHT) OneHundredAndNinety.pack(side=tkinter.RIGHT) servo.mainloop()